September 2021
Beginner to intermediate
352 pages
11h 27m
English
Python programs are organized into modules and packages that are loaded with the import statement. This chapter describes the module and package system in more detail. The primary focus is on programming with modules and packages, not the process of bundling code for deployment to others. For the latter, consult the latest documentation at https://packaging.python.org/tutorials/packaging-projects/.
import StatementAny Python source file can be imported as a module. For example:
# module.py a = 37 def func(): print(f'func says that a is {a}') class SomeClass: def method(self): print('method says hi') print('loaded module')
This file contains common programming elements—including ...