Victor Varvariuc added the comment:

> it is possible for module a to override its attribute b without updating 
> sys.modules

This sounds like a really strange application.

Even if someone overrides the attribute, when you do in other place `import 
a.b.c as m` you expect `a.b.c` to be path to a module, otherwise it would be 
hard to debug. 

The docs https://docs.python.org/3/reference/simple_stmts.html#import say 
`import_stmt     ::=  "import" module ["as" name]` meaning everywhere that 
`module` is a path to a module.

https://docs.python.org/3/reference/import.html#searching

> To begin the search, Python needs the fully qualified name of the module (or 
> package, but for the purposes of this discussion, the difference is 
> immaterial) being imported. This name may come from various arguments to the 
> import statement, or from the parameters to the importlib.import_module() or 
> __import__() functions.

So if you treat `import a.b.c as m` as `import a; m = a.b.c` -- it go go in 
some cases against the docs.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30024>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to