Get name of class without instance

Christian Heimes lists at
Wed Jun 24 23:59:52 CEST 2009

Terry Reedy wrote:
> Bryan wrote:
>> How come dir(Foo) does not show __name__?  That is how I was
>> investigating the possibilities.
> Interesting question. Seems like an oversight. dir(some_module) and
> dir(some_function) include '__name__'. I suggest you search the tracker
> for existing issues on this subject and add a feature request if there
> is none.

The __name__ attribute of types and classes is actually a descriptor of
the metaclass. It doesn't show up just like __bases__ and a few others.

However for modules __name__ is just an ordinary attribute that gets set
by the module class.


More information about the Python-list mailing list