hidden attributes
Michele Simionato
mis6 at pitt.edu
Tue Dec 17 14:04:30 EST 2002
I've just discovered that the attribute __name__ is hidden i.e.
not shown by dir:
>>> class C: pass
...
>>> C.__name__
'C'
>>> dir(C)
['__doc__', '__module__'] # __name__ is not shown
>>> help(dir)
Help on built-in function dir:
dir(...)
dir([object]) -> list of strings
Return an alphabetized list of names comprising (some of) the attributes
^^^^^^^
of the given object, and of attributes reachable from it:
No argument: the names in the current scope.
Module object: the module attributes.
Type or class object: its attributes, and recursively the attributes of
its bases.
Otherwise: its attributes, its class's attributes, and recursively the
attributes of its class's base classes.
Why __name__ is hidden and how do I discover if there other hidden
attributes I don't know about ?
--
Michele Simionato - Dept. of Physics and Astronomy
210 Allen Hall Pittsburgh PA 15260 U.S.A.
Phone: 001-412-624-9041 Fax: 001-412-624-9163
Home-page: http://www.phyast.pitt.edu/~micheles/
More information about the Python-list
mailing list