Hussein B <[EMAIL PROTECTED]> writes: > 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)
Use it when your method needs to know what class it is called from. This makes sense in the context of subclassing: class M(object): @classmethod def method(cls, x): print cls, x class N(M): pass >>> M.method(1) <class '__main__.M'> 1 >>> N.method(1) <class '__main__.N'> 1 -- http://mail.python.org/mailman/listinfo/python-list