Packages in Python

ModulesFile Handling

Packages are a way to organize related modules into directories. They help structure larger projects and avoid name conflicts.

A package is a folder containing Python modules and a special __init__.py file (can be empty in Python 3.3+).

Basic Package Structure

Example structure: my_package/ __init__.py module1.py module2.py

Importing from Packages

__init__.py – Package Initialization

This file runs when the package is imported. Use it to set up imports or variables.

Relative Imports

Inside packages, use . for current, .. for parent.

Quick Quiz

We have reviewed and checked the materials, but errors may still occur. The content is provided for educational purposes only, so use it at your own responsibility and verify with other sources if needed.

✨ Ask Lara — your AI study partner

Unlock personalized learning support. Lara can explain lessons, summarize topics, and answer your study questions — available from the Go plan and above.


Lara helps you learn faster — exclusive to ReadyTools Go, Plus, and Max members.

Track Your Progress 🚀

Learn more easily by tracking your progress completely for free.