I like to use full namespaces in python when it comes to modules/libraries for readability. I'm wondering why this doesn't work the the xml library. I figure import xml
will also import etree and everything else in the namespace. At least that's behavior I've noticed for other modules.
$ ptpython
>>> import xml
>>> dir(xml.etree.ElementTree)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'etree'
'module' object has no attribute 'etree'
>>> import xml.etree.ElementTree
>>> dir(xml.etree.ElementTree)
['Comment', 'Element', 'ElementPath', 'ElementTree', 'HTML_EMPTY', 'PI',...]
Two questions:
- Why is this happening with the xml library?
- Is there a way to import it all with something short like
import xml
?