Python noob can't get class method to work

后端 未结 2 564
孤街浪徒
孤街浪徒 2021-01-27 02:31

I have a method in my Customer class called save_from_row(). It looks like this:

@classmethod
def save_from_row(row):
    c = Customer(         


        
2条回答
  •  隐瞒了意图╮
    2021-01-27 03:04

    You want:

    @classmethod
    def save_from_row(cls, row):
    

    Class methods get the method's class as the first argument.

提交回复
热议问题