Class methods

Laszlo Zsolt Nagy gandalf at designaproduct.biz
Wed Oct 5 14:51:57 EDT 2005


>>    
>>
>Oh man, it has been a long time I have read such an disturbing question.
>
>RTMF here:  http://docs.python.org/lib/built-in-funcs.html#l2h-14
>  
>
I feel I was a bit harsh.

class A(object):
    x = 0
    @classmethod
    def f(cls):
       cls.x += 1
       print "x is",cls.x

 >>> A.f()
x is 1
 >>> A.f()
x is 2
 >>> A.f()
x is 3

Ashes to my head. :-(

   Les




More information about the Python-list mailing list