Search code examples
pythonargumentstypeerror

Why am i getting a missing 1 required positional argument: 'connectionList' error but can print connectionList?


could you please explain why connectionList doesn't seems to get passed to the connectionMaker method ?

Output of the print : 
[('tFrictionpushButton', 'None', 'clicked', 'open_tFriction'), 
('tGravitypushButton', 'None', 'clicked', 'open_tGravity'), 
('pushButton_connect', 'None', 'clicked', 'pressConnectButton'), 
('lineEdit_address', 'None', 'textChanged', 'saveConnectionConfig')]


code :
def descriptorConnections(self, aliasList, connectionList):
    print(connectionList)
    AutoConnects.connectionMaker(connectionList)

Solution

  • Exactly as the error says, connectionMaker is missing an argument. Its connectionList is the second argument that it's expecting, and you only provided the first argument.

    Since you didn't provide the definition of AutoConnects.connectionMaker, I have to guess, but I'm guessing that the expected first argument is a self instance. If that's the case, you should be able to fix it by doing:

    AutoConnects().connectionMaker(connectionList)
    

    Or maybe in your own class's __init__ you want to create a single AutoConnects instance:

    self.connects = AutoConnects()
    

    and then in your other methods you can refer to that instance:

    self.connects.connectionMaker(connectionList)