__getattribute__ for class object
Steven Bethard
steven.bethard at gmail.com
Fri Aug 12 13:27:54 EDT 2005
Dan wrote:
> Depending on what you want to do, it might be better to use properties
> instead:
>
> class Meta(type):
> x = property(lambda klass: 'Called for '+str(klass))
>
> class Foo(object):
> __metaclass__=Meta
Also worth noting that you can inline the metaclass if you don't need it
anywhere else, e.g.:
class Foo(object):
class __metaclass__(type):
x = property(lambda klass: 'Called for '+str(klass))
STeVe
More information about the Python-list
mailing list