To be able to use modules and packages within your Python programs, you need to understand how they work. In this chapter, we will examine the nuts and bolts of how modules and packages are defined and used in Python. In particular, we will:
Review how Python modules and packages are defined
See how packages can be created inside other packages
Discover how modules and packages can be initialized
Learn more about the import process
Explore the notion of relative imports
Learn how to control what gets imported
Find out how to deal with circular dependencies
See how a module can be run directly from the command line, and why this can be useful