Skip to main content

6. What is a Package?

A package is a folder that contains multiple related modules. Example structure:
Packages help organize larger Python projects.

7. What is __init__.py?

__init__.py is a special file inside a package. It tells Python that the directory should be treated as a package (especially in older Python versions) and can also run initialization code or expose selected functions. Example:

utils.py


init.py


main.py

Output
Without importing greet in __init__.py, you would write:

8. Importing Modules from a Package

Folder structure:

calculator.py


main.py

Output

6. What is a Package?

A package is a folder that contains multiple related modules. Example structure:
Packages help organize larger Python projects.

7. What is __init__.py?

__init__.py is a special file inside a package. It tells Python that the directory should be treated as a package (especially in older Python versions) and can also run initialization code or expose selected functions. Example:

utils.py


init.py


main.py

Output
Without importing greet in __init__.py, you would write:

8. Importing Modules from a Package

Folder structure:

calculator.py


main.py

Output