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

SourceForge.net noreply at sourceforge.net
Thu Oct 12 14:48:15 CEST 2006


Bugs item #1534014, was opened at 2006-08-03 17:23
Message generated for change (Comment added) made by gbrandl
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: Closed
>Resolution: Duplicate
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)




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

>Comment By: Georg Brandl (gbrandl)
Date: 2006-10-12 12:48

Message:
Logged In: YES 
user_id=849994

Duplicate of #945861.

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

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