Importing a package does not import submodule automatically. You need to import submodule explicitly.
For example, import xml
does not import the submodule xml.dom
>>> import xml
>>> xml.dom
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'dom'
>>> import xml.dom
>>> xml.dom
<module 'xml.dom' from 'C:Python27libxmldom\__init__.pyc'>
There's an exception like os.path
. (os
module itself import the submodule into its namespace)
>>> import os
>>> os.path
<module 'ntpath' from 'C:Python27lib
tpath.pyc'>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…