I have a method in my Customer
class called save_from_row()
. It looks like this:
@classmethod
def save_from_row(row):
c = Customer(
The first argument to a classmethod
is the class itself. Try
@classmethod
def save_from_row(cls, row):
c = cls()
# ...
return c
or
@staticmethod
def save_from_row(row):
c = Customer()
# ...
return c
The classmethod
variant will enable to create subclasses of Customer
with the same factory function.
Instead of the staticmethod
variant, I'd usually use module-level functions.
You want:
@classmethod
def save_from_row(cls, row):
Class methods get the method's class as the first argument.