Module 7: Python Modules and Packages
Intermediate 9 chapters
87. Introduction to Modules
Understand what a Python module is, why programs are split into modules, and how to look inside a module with dir(), help() and its attributes.
88. Import Statement
Learn every common form of the import statement: import, import as, from import, from import as and the star import, and when to use each.
89. Built-in Modules
Take a guided tour of useful standard library modules: math, random, datetime, json, collections, itertools, os.path, string and sys, with runnable examples.
90. Creating Custom Modules
Learn how to turn your own .py file into a reusable module, import it from other files, and use the __name__ guard so a file can be both a module and a script.
91. Python Packages
Learn how folders of modules become packages, how __init__.py works, and how to import between modules inside a package with absolute and relative imports.
92. pip Package Manager
Learn what pip is, how to install, upgrade, list and remove packages, how requirements files and version specifiers work, and how to check packages from Python code.
93. Virtual Environments
Understand why every project needs its own virtual environment, how to create, activate and delete one with venv, and how to keep its packages in a requirements file.
94. Installing External Packages
Learn how to install third-party packages with pip, choose versions, upgrade and remove them, check what is installed, and handle missing packages safely in your code.
95. Python Standard Library
Take a guided tour of the most useful standard library modules: math, statistics, collections, itertools, datetime, json, pathlib, textwrap and more, with runnable examples.