Home TypeError: Missing 1 required positional argument: 'self'
Reply: 0

TypeError: Missing 1 required positional argument: 'self'

user1137 Published in March 24, 2018, 12:25 am

I am new to python and have hit a wall. I followed several tutorials but cant get past the error:

Traceback (most recent call last):
  File "C:\Users\Dom\Desktop\test\test.py", line 7, in <module>
    p = Pump.getPumps()
TypeError: getPumps() missing 1 required positional argument: 'self'

I examined several tutorials but there doesn't seem to be anything different from my code. The only thing I can think of is that python 3.3 requires different syntax.

main scipt:

# test script

from lib.pump import Pump

print ("THIS IS A TEST OF PYTHON") # this prints

p = Pump.getPumps()

print (p)

Pump class:

import pymysql

class Pump:

    def __init__(self):
        print ("init") # never prints

    def getPumps(self):
                # Open database connection
                # some stuff here that never gets executed because of error

If I understand correctly "self" is passed to the constructor and methods automatically. What am I doing wrong here?

I am using windows 8 with python 3.3.2

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.391302 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO