[docs] [issue28745] Python 3.5.2 "from ... import" statement is different from official documentation

Josh Rosenberg report at bugs.python.org
Sat Nov 19 01:52:26 EST 2016


Josh Rosenberg added the comment:

Why is this unexpected? Per the docs, the process is:

    find the module specified in the from clause, loading and initializing it if necessary;
    for each of the identifiers specified in the import clauses:
        check if the imported module has an attribute by that name
***     if not, attempt to import a submodule with that name and then check the imported module again for that attribute
        if the attribute is not found, ImportError is raised.
        otherwise, a reference to that value is stored in the local namespace, using the name in the as clause if it is present, otherwise using the attribute name

The *** is next to where it ends up in the tree; it found the l007 package, determined it had no attribute named l009, determined it did have a module of that name, and imported it. What were you expecting? For the record, it would be nice if you'd used a name that didn't begin with a lowercase L; it makes it look like the module is named entirely with digits (which would be illegal).

----------
nosy: +josh.r

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28745>
_______________________________________


More information about the docs mailing list