Created on 2008-10-10 21:35 by Antoine d'Otreppe, last changed 2022-04-11 14:56 by admin. This issue is now closed.
| Messages (5) | |||
|---|---|---|---|
| msg74648 - (view) | Author: Antoine d'Otreppe (Antoine d'Otreppe) | Date: 2008-10-10 21:35 | |
Hello
See the following code and comments for explanation ;) (Try it with
interactive mode)
---
>>> class A:
... class B:
... pass
>>> A
<class __main__.A at 0x...>
>>> A.B
<class __main__.B at 0x...>
>>> B
NameError: B is not defined
---
This seems to be inconsistent, as Python represents A.B as __main__.B,
but B is not accessable from __main__
Maybe this could be better:
---
>>> A.B
<class __main__.A.B at 0x...>
^
---
|
|||
| msg74649 - (view) | Author: Benjamin Peterson (benjamin.peterson) * | Date: 2008-10-10 21:40 | |
This is because type_repr looks at the __module__ attribute to determine the location. Fixing this would probably require adding a __nestedclass__ attribute. However, nested classes aren't used very much, so it's not urgent by any means. |
|||
| msg74672 - (view) | Author: Martin v. Löwis (loewis) * | Date: 2008-10-12 17:23 | |
I'm tempted to close this as "won't fix". |
|||
| msg74673 - (view) | Author: Georg Brandl (georg.brandl) * | Date: 2008-10-12 17:34 | |
Me too. There are too many cases where class statements can be executed to get this right. |
|||
| msg74944 - (view) | Author: Terry J. Reedy (terry.reedy) * | Date: 2008-10-17 22:38 | |
I consider the request invalid. Continue the example with B=A.B B The repr of an object cannot now and should not depend on the access path. =or= class C: pass class D: pass D C.D = D C.D Same comment. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:40 | admin | set | github: 48354 |
| 2008-10-17 22:38:19 | terry.reedy | set | nosy:
+ terry.reedy messages: + msg74944 |
| 2008-10-12 18:03:37 | loewis | set | status: open -> closed |
| 2008-10-12 17:34:38 | georg.brandl | set | nosy:
+ georg.brandl messages: + msg74673 |
| 2008-10-12 17:23:01 | loewis | set | resolution: wont fix messages: + msg74672 nosy: + loewis |
| 2008-10-10 21:40:50 | benjamin.peterson | set | priority: low nosy: + benjamin.peterson messages: + msg74649 |
| 2008-10-10 21:35:35 | Antoine d'Otreppe | create | |