Chapter 10. Modules and scoping rules
This chapter covers:
- Defining a module
- Writing a first module
- Using the import statement
- Modifying the module search path
- Making names private in modules
- Importing standard library and third-party modules
- Understanding Python scoping rules and namespaces
Modules are used to organize larger Python projects. The Python standard library is split into modules to make it more manageable. You don’t need to organize your own code into modules, but if you’re writing any programs that are more than a few pages long or any code that you want to reuse, you should probably do so.
A module is a file containing code. It defines a group of Python functions or other objects, and the name of the module is derived from the name of the file.