I've experiment with the statement,however the result did not match the official description.
Quotation is below:
The from form uses a slightly more complex process:
- 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
See this documentation:
When a submodule is loaded using any mechanism (e.g.
import-fromstatements, or built-in
__import__()) a binding is placed in the parent module’s namespace to the submodule object. For example, if package
spamhas a submodule
foo, after importing
spamwill have an attribute
foowhich is bound to the submodule.
That is why the steps in your quote are in the order they are in. Even though
l007 doesn't initially have an attribute
l009, it will have one after the submodule import occurs.