On Aug 24, 6:32 pm, Hussein B <[EMAIL PROTECTED]> wrote: > Hi, > I'm familiar with static method concept, but what is the class method? > how it does differ from static method? when to use it? > -- > class M: > def method(cls, x): > pass > > method = classmethod(method) > -- > Thank you for your time.
Firstly, don't use method = classmethod(method). Decorators are far better. The following code has the same effect: class M: @classmethod def method(cls, x): pass Far more readable, right? Class methods are useful if you've got lots of inheritance happening. The first argument passed in is the class calling the method. Handy for a mix-in: it can add methods affecting the actual class it's mixed into, rather than messing with the mix-in itself. -- http://mail.python.org/mailman/listinfo/python-list