So far, every program has been a single file. Real projects span many files, grouped into folders. Modules are single files of Python code; packages are folders that hold them.
What’s in this section
- Importing modules —
import,from, andas - Creating your own modules — splitting a script into reusable files
- Packages — folders of modules
- The standard library — a tour of what comes with Python
- Running modules as scripts —
python -mandif __name__ == "__main__"
Once you can split code across files cleanly, you’re ready to read and write programs at any scale.