Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace inconsistency #48354

Closed
AntoinedOtreppe mannequin opened this issue Oct 10, 2008 · 5 comments
Closed

Namespace inconsistency #48354

AntoinedOtreppe mannequin opened this issue Oct 10, 2008 · 5 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@AntoinedOtreppe
Copy link
Mannequin

AntoinedOtreppe mannequin commented Oct 10, 2008

BPO 4104
Nosy @loewis, @birkenfeld, @terryjreedy, @benjaminp

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2008-10-12.18:03:37.160>
created_at = <Date 2008-10-10.21:35:35.644>
labels = ['interpreter-core', 'type-feature']
title = 'Namespace inconsistency'
updated_at = <Date 2008-10-17.22:38:19.295>
user = 'https://bugs.python.org/AntoinedOtreppe'

bugs.python.org fields:

activity = <Date 2008-10-17.22:38:19.295>
actor = 'terry.reedy'
assignee = 'none'
closed = True
closed_date = <Date 2008-10-12.18:03:37.160>
closer = 'loewis'
components = ['Interpreter Core']
creation = <Date 2008-10-10.21:35:35.644>
creator = "Antoine d'Otreppe"
dependencies = []
files = []
hgrepos = []
issue_num = 4104
keywords = []
message_count = 5.0
messages = ['74648', '74649', '74672', '74673', '74944']
nosy_count = 5.0
nosy_names = ['loewis', 'georg.brandl', 'terry.reedy', 'benjamin.peterson', "Antoine d'Otreppe"]
pr_nums = []
priority = 'low'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue4104'
versions = ['Python 2.5']

@AntoinedOtreppe
Copy link
Mannequin Author

AntoinedOtreppe mannequin commented Oct 10, 2008

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...>
                  ^

@AntoinedOtreppe AntoinedOtreppe mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement labels Oct 10, 2008
@benjaminp
Copy link
Contributor

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.

@loewis
Copy link
Mannequin

loewis mannequin commented Oct 12, 2008

I'm tempted to close this as "won't fix".

@birkenfeld
Copy link
Member

Me too. There are too many cases where class statements can be executed
to get this right.

@loewis loewis mannequin closed this as completed Oct 12, 2008
@terryjreedy
Copy link
Member

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.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants