As far as I know, correct me if I am wrong.
First, import a.b
must import a module(a file) or a package(a directory contains __init__.py
).
For example, you can import tornado.web as web
but you cannot import flask.Flask as Flask
as Flask
is an object in package flask
.
Second, import a.b
also import the namespace a
which from a import b
won't. You can check it by globals()
.
So what's the influence? For example:
import tornado.web as web
Now you have access to namespace tornado
, but you cannot access tornado.options
even though tornado
has this module. But as python's global package management, if you from tornado import options
, you will not only get access to options
but also add it to namespace tornado
. So now you can also access options
by tornado.options
.