Caffeinated Coder
Book an appointment
Lesson 15 · Real programs

Modules and packages

Real programs are split across many files. A module is one .py file, and a package is a folder of modules. Step through a five-line main.py that imports greet.py and shapes/square.py. Watch Python search sys.path, run each module once, save it in sys.modules, and reuse it on the next import. Then see what __name__ == "__main__" is for, and what a misspelt import does.

14 min11 steps5 questionsBeginner
Fig 15 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.