Class's metafunction problem
Gregor Mirai
gregmi at email.si
Fri Oct 18 08:15:43 EDT 2002
> 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
More information about the Python-list
mailing list