Class property (was: Class methods)

Peter Otten __peter__ at web.de
Thu Oct 6 05:29:24 EDT 2005


Laszlo Zsolt Nagy wrote:

> I was trying for a while, but I could not implement a 'classproperty'
> function. Is it possible at all?

You could define a "normal" property in the metaclass:

>>>>> class A:
...     class __metaclass__(type):
...             @property
...             def clsprp(cls): return 42
...
>>> A.clsprp
42

Peter




More information about the Python-list mailing list