Ich bin neu in Python und habe eine Wand getroffen. Ich habe mehrere Tutorials befolgt, kann aber den Fehler nicht überwinden:
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'
Ich habe mehrere Tutorials untersucht, aber es scheint nichts anderes zu geben als mein Code. Ich kann mir nur vorstellen, dass Python 3.3 eine andere Syntax erfordert.
Hauptskript:
# test script
from lib.pump import Pump
print ("THIS IS A TEST OF PYTHON") # this prints
p = Pump.getPumps()
print (p)
Pumpenklasse:
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
Wenn ich das richtig verstehe, wird "self" automatisch an den Konstruktor und die Methoden übergeben. Was mache ich hier falsch?
Ich verwende Windows 8 mit Python 3.3.2