[ python-Bugs-1534014 ] __name__ doesn't show up in dir() of class

SourceForge.net noreply at sourceforge.net
Thu Aug 3 19:30:48 CEST 2006


Bugs item #1534014, was opened at 2006-08-03 12:23
Message generated for change (Settings changed) made by gumnos
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1534014&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Type/class unification
Group: Python 2.4
Status: Open
Resolution: None
>Priority: 4
Submitted By: Tim Chase (gumnos)
Assigned to: Nobody/Anonymous (nobody)
Summary: __name__ doesn't show up in dir() of class

Initial Comment:
The __name__ attribute doesn't appear in the dir() of a
class, yet is an available attribute.

The below reproduces the problem:

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

Note that this is different from the attribute
appearing in an *instance* of the class, as in

>>> x = Foo()
>>> '__name__' in dir(x)




----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1534014&group_id=5470


More information about the Python-bugs-list mailing list