Get name of class without instance

Christian Heimes lists at cheimes.de
Wed Jun 24 17:59:52 EDT 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.

Christian




More information about the Python-list mailing list