6.14. Packages

In chapter 3, when we proved the existence of the XML package, we executed a program called testpyexpat.py. If you looked inside this program, you will have seen that the first executable line looks like this:

CD-ROM reference=6048.txt
from xml.parsers import pyexpat

This is another variation on the syntax of an import statement. A collection of modules can be organized into a hierarchical collection of submodules. Any dots in a module name are interpreted as separating the overall module collection (or package) into submodules.

Typically, the dotted module names will map onto directory hierachies. So, for example, we can tell by looking at the above import statement that there is a subdirectory called parsers in the XML package ...

Get XML Processing with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.