As programs become larger, simply writing more code in a single file becomes unmanageable. Keeping related functions and data together, avoiding naming conflicts, and reusing code across different projects are essential for efficient development. This chapter introduces Python's mechanisms for achieving this organization: modules and packages.
You will learn how to structure your code into separate files called modules and how to use the import
statement to access code defined in other modules. We will cover Python's extensive standard library, a collection of pre-built modules ready for use. You will also learn how to find, install, and use third-party packages from the Python Package Index (PyPI) using the pip
tool. Finally, we will look at the basic structure for organizing your own modules into packages. This foundational knowledge is key to building larger, maintainable Python applications.
7.1 What are Modules?
7.2 Importing Modules: import Statement
7.3 Importing Specific Names: from ... import
7.4 Python's Standard Library Overview
7.5 Finding and Installing External Packages with pip
7.6 Commonly Used Standard Modules
7.7 Organizing Code into Packages (Basic Structure)
7.8 Practice: Using Standard and External Modules
© 2025 ApX Machine Learning