__init.py__
What is __init__.py
?
__init__.py
?__init__.py
is a special file that tells Python:
βThis folder is a package β it can be imported.β
Without it (in older Python versions), Python would not treat a directory as importable.
Project Layout
π mathlib/calculator.py
mathlib/calculator.py
π mathlib/geometry.py
mathlib/geometry.py
π mathlib/__init__.py
mathlib/__init__.py
Now you can just do
from mathlib import Calculator
instead offrom mathlib.calculator import Calculator
.
π main.py
main.py
βΆ How to Run
Make sure you're in the mathlib_project/
directory, then run:
β
Output
Last updated
Was this helpful?