Class's metafunction problem
Gregor Mirai
gregmi at email.si
Fri Oct 18 08:15:43 EDT 2002
More information about the Python-list mailing list
Fri Oct 18 08:15:43 EDT 2002
- Previous message (by thread): Class's metafunction problem
- Next message (by thread): RELEASED ht2html 2.0
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> class A(object): > x = 0 > def set_x(cls, val): > cls.x = val > set_x = classmethod(set_x) > > > >>> a = A() > >>> print a.x > 0 > >>> A.set_x(37) > >>> print a.x > 37 > > I think that classmethod only works with new-style classes, and only in > recent versions of python. see the docs for more information. see also > "staticmethod". > Tnx, it works splendidly (also for classic classes) in python 2.2 and later :), Greg
- Previous message (by thread): Class's metafunction problem
- Next message (by thread): RELEASED ht2html 2.0
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list