This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: __name__ doesn't show up in dir() of class
Type: Stage:
Components: Interpreter Core Versions: Python 2.4
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, gumnos
Priority: low Keywords:

Created on 2006-08-03 17:23 by gumnos, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg29432 - (view) Author: Tim Chase (gumnos) Date: 2006-08-03 17:23
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)


msg29433 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-10-12 12:48
Logged In: YES 
user_id=849994

Duplicate of #945861.
History
Date User Action Args
2022-04-11 14:56:19adminsetgithub: 43769
2006-08-03 17:23:11gumnoscreate