Python: __init__() takes exactly 2 arguments (3 given)

Yes, the OP missed the self, but I don't even know what those tuples-as-arguments mean and I'm intentionally not bothering to figure it out, it's just a bad construction.

Codysehi, please contrast your code with:

class Adapter:
    def __init__(self, side1, side2):
        self.side1 = side1
        self.side2 = side2

sideX = ('rca', 'm')
sideY = ('bnc', 'f')
x = Adapter(sideX, sideY)

and see that it is both more readable, and does what I think you intend.


Method calls automatically get a 'self' parameter as the first argument, so make __init__() look like:

def __init__(self, (pType1,pMF1),(pType2,pMF2)):

This is usually implicit in other languages, in Python it must be explicit. Also note that it's really just a way of informing the method of the instance it belongs to, you don't have to call it 'self'.


Your __init__ should look like this:

def __init__(self,(pType1,pMF1),(pType2,pMF2)):

Tags:

Python