hidden attributes

Terry Reedy tjreedy at udel.edu
Tue Dec 17 14:57:24 EST 2002


"Michele Simionato" <mis6 at pitt.edu> wrote in message
news:2259b0e2.0212171104.34448753 at posting.google.com...
> I've just discovered that the attribute __name__ is hidden i.e.
> Why __name__ is hidden

for classes? don't know.  It's not for modules.

>and how do I discover if there other hidden
> attributes I don't know about ?

Read all the docs and put one plus one plus ...one together -- or, for
new-style classes, wait until new docs and then see if still
deficient.  __dict__ is hidden for classic classes, as in your
example, and modules, but not for new classes (or their instances):

>>> class C(object): pass
...
>>> dir(C)
['__class__', '__delattr__', '__dict__', '__doc__',
'__getattribute__', '__hash_
_', '__init__', '__module__', '__new__', '__reduce__', '__repr__',
'__setattr__'
, '__str__', '__weakref__']
>>> C.__name__
'C'

__metaclass__ and __new__ are also missing above.

Terry J. Reedy





More information about the Python-list mailing list