Modules and imports

A module is a reusable Python file, a package is a folder of modules. You load them with import or from ... import .... Each module has its own namespace, which avoids collisions. The if __name__ == '__main__': block distinguishes direct execution from import.

Example

from pathlib import Path
import math

Related concepts

The whole glossary