Packages in Python
Packages in Python
We learned that modules are files containing Python statements and definitions, like function and
class definitions. We will learn in this chapter how to bundle multiple modules together to form a
package.
A package is basically a directory with Python files and a file with the name __init__.py. This
means that every directory inside of the Python path, which contains a file named __init__.py, will
be treated as a package by Python. It's possible to put several modules into a Package.
Similarly, as a directory can contain subdirectories and files, a Python package can have sub-
packages and modules.
A directory must contain a file named __init__.py in order for Python to consider it as a
package.