Getting a class name
Michele Simionato
michele.simionato at gmail.com
Sun Feb 18 08:22:26 EST 2007
On Feb 18, 1:24 pm, "Fuzzyman" <fuzzy... at gmail.com> wrote:
> Why is the __name__ attribute not available to the instance? Why don't
> normal lookup rules apply (meaning that a magic attribute will be
> looked up on the class for instances) ?
Because __name__ isn't really an attribute, it is a descriptor defined
on
the metaclass:
>>> type(type.__dict__['__name__'])
<type 'getset_descriptor'>
See http://users.rcn.com/python/download/Descriptor.htm for a guide to
descriptors, and the papers by me and David Mertz for a guide to
metaclasses.
Michele Simionato
More information about the Python-list
mailing list