[docs] [issue14628] Clarify import statement documentation regarding what gets bound
report at bugs.python.org
Fri Apr 20 06:31:07 CEST 2012
New submission from Eric Snow <ericsnowcurrently at gmail.com>:
(see #14609 and #14582)
The specification for the import statement says the following:
"The first form of import statement binds the module name in the local namespace to the module object".
This is not the case and has not been the case perhaps ever. Instead of getting bound to the module (returned by loader.load_module() during import), the name is bound to the value at sys.modules[module_name].
Normally two approaches yield the same result. However, if during import the sys.modules value for the module is assigned to something else, the behavior deviates from the specfication. See #14609 for an example.
Considering the backwards-compatibility issues, the language reference should be updated to reflect the actual behavior.
assignee: docs at python
nosy: benjamin.peterson, brett.cannon, docs at python, eric.snow
title: Clarify import statement documentation regarding what gets bound
versions: Python 2.7, Python 3.2, Python 3.3
Python tracker <report at bugs.python.org>
More information about the docs