[issue15598] relative import unexpectedly binds name
New submission from Antony Lee: The language reference is clear: The from form does not bind the module name (Section 6.12) However, consider the following example: * package/__init__.py: foo = FOO from .foo import bar print(foo) os = OS from os import path print(os) * package/foo.py: foo = 42 Now import package results in printing: module 'pypackage.foo' from 'pypackage/foo.py' OS i.e., the relative from ... import has not only bound bar, but also foo, which seems to contradict the documentation. (I get the same behaviour using 3.2.3 as well as 2.7.3.) -- messages: 167742 nosy: Antony.Lee priority: normal severity: normal status: open title: relative import unexpectedly binds name versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15598 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15598] relative import unexpectedly binds name
Changes by STINNER Victor victor.stin...@gmail.com: -- nosy: +brett.cannon ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15598 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15598] relative import unexpectedly binds name
Benjamin Peterson added the comment: I don't think this is incorrect. Importing a submodule implicit sets its name in the package scope, which is __init__'s module scope. -- nosy: +benjamin.peterson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15598 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15598] relative import unexpectedly binds name
Eric Snow added the comment: I agree with Benjamin. The name is not bound due to the from-import statement. -- nosy: +eric.snow ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15598 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15598] relative import unexpectedly binds name
Changes by Benjamin Peterson benja...@python.org: -- resolution: - invalid status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15598 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com