8. Modules, Packages, and Distribution
Large Python programs are organized into modules and packages. In addition, a large number of modules are included in the Python standard library. This chapter describes the module and package system in more detail. In addition, it provides information on how to install third-party modules and distribute source code.
Modules and the import
Statement
Any Python source file can be used as a module. For example, consider the following code:
To load this code as a module, use the statement import spam
. The first time import
is used to load a module, it does three things:
1. It creates a new namespace that serves ...
Get Python: Essential Reference 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.