[issue22790] some class attributes missing from dir(Class)

Georg Brandl report at bugs.python.org
Tue Nov 4 10:59:59 CET 2014


Georg Brandl added the comment:

"Attributes from the metaclass have always been excluded from the dir() of a class."

Be that as it may, I think it is wrong.  I can understand excluding methods of the metaclass, but __qualname__ (and friends) are only defined in the metaclass because they are properties and not __dict__ members, but they are regular attributes of the class, not of the metaclass.

E.g. why is __module__ in there and not __qualname__? Both are determined dynamically at class creation time.

The answer is that it's an implementation detail: there is no tp_module (or ht_module) member in the PyHeapTypeObject struct to store it, so it's stored in __dict__, while __qualname__ is stored in a struct member.

----------
nosy: +pitrou

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22790>
_______________________________________


More information about the Python-bugs-list mailing list