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\
You can call the method like pump.getPumps()
. By adding @classmethod
decorator on the method. A class method receives the class as the implicit first argument, just like an instance method receives the instance.
class Pump:
def __init__(self):
print ("init") # never prints
@classmethod
def getPumps(cls):
# Open database connection
# some stuff here that never gets executed because of error
So, simply call Pump.getPumps()
.
In java, it is termed as static
method.