On Wed, Aug 10, 2011 at 8:48 AM, Fuzzyman <fuzzy...@gmail.com> wrote: > __name__ can be a descriptor, so you just need to write a descriptor > that can be fetched from classes as well as instances. > > Here's an example with a property (instance only): > >>>> class Foo(object): > ... @property > ... def __name__(self): > ... return 'bar' > ... >>>> Foo().__name__ > 'bar'
But: >>> Foo.__name__ 'Foo' >>> repr(Foo()) '<__main__.Foo object at 0x00CAFFD0>' >>> Foo.__dict__['__name__'] <property object at 0x00CBA6F0> It seems that Foo.__name__ and Foo.__dict__['__name__'] are not the same thing, and Python itself only uses the former. -- http://mail.python.org/mailman/listinfo/python-list