TypeError: Missing 1 required positional argument: 'self' TypeError: Missing 1 required positional argument: 'self' python python

TypeError: Missing 1 required positional argument: 'self'


You need to instantiate a class instance here.

Use

p = Pump()p.getPumps()

Small example -

>>> class TestClass:        def __init__(self):            print("in init")        def testFunc(self):            print("in Test Func")>>> testInstance = TestClass()in init>>> testInstance.testFunc()in Test Func


You need to initialize it first:

p = Pump().getPumps()


Works and is simpler than every other solution I see here :

Pump().getPumps()

This is great if you don't need to reuse a class instance. Tested on Python 3.7.3.


matomo