When should I use @classmethod and when def method(self)?
问题 While integrating a Django app I have not used before, I found two different ways used to define functions in classes. The author seems to use them both very intentionally. The first one is one I myself use a lot: class Dummy(object): def some_function(self,*args,**kwargs): do something here self is the class instance The other one is one I do not use, mostly because I do not understand when to use it, and what for: class Dummy(object): @classmethod def some_function(cls,*args,**kwargs): do