classification
Title: Nested class __name__
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: georg.brandl, gvanrossum (2)
Priority: low Keywords:

Created on 2002-11-05 17:56 by gvanrossum, last changed 2007-03-10 18:21 by gvanrossum.

Messages (5)
msg13078 - (view) Author: Guido van Rossum (gvanrossum) Date: 2002-11-05 17:56
The __name__ attribute of a nested class should be set
to 'outer.inner', both for classic and for new-style
classes. E.g.

>>> class C:
...     class C1: pass
... 
>>> C.C1.__name__
'C.C1'
>>> 
msg13079 - (view) Author: Guido van Rossum (gvanrossum) Date: 2002-11-14 23:13
Logged In: YES 
user_id=6380

Hm, but should this also be done for functions inside
classes?  E.g.

class C:
 def foo(self): pass

assert C.foo.__name__ == "C.foo"
assert C.__dict__["foo"].__name__ == "C.foo"

And what about classes inside functions?

def f():
  class C: pass
  return C

assert f().__name__ == "f.C"

???
msg13080 - (view) Author: Guido van Rossum (gvanrossum) Date: 2003-02-11 23:01
Logged In: YES 
user_id=6380

I'm less sure I even want this now, and not at all sure how
to do it any more, so lowering priority.
msg13081 - (view) Author: Georg Brandl (georg.brandl) Date: 2007-03-10 07:22
Any interest for Python 3000 on this? Otherwise we can close it.
msg13082 - (view) Author: Guido van Rossum (gvanrossum) Date: 2007-03-10 18:21
I don't think so.  Closing.
History
Date User Action Args
2002-11-05 17:56:34gvanrossumcreate