CertGrid CertGrid
Hands-on Lab·Certified Associate Python Programmer

Python Modules and Packages

PCAP objective 1.5 is create and use user-defined modules and packages, and there is much less machinery than people expect: a module is a `.py` file, a package is a directory containing `__init__.py`, and being importable means being somewhere on `sys.path`. The examinable subtleties are that `__init__.py` runs when the package is imported, and that importing a package does **not** import its submodules.

Modules and Packages Guide 8 of 25 Intermediate

Written against the versions above. Since Python 3.3 a directory without `__init__.py` can still be imported as a **namespace package**. The exam expects `__init__.py`, and this guide uses it - but do not be surprised when a real project omits it.

One machine, and any shell with Python 3 will do - these exams test the language, not a distribution.
Server NameIP AddressOSRolesCPURAMHDD
RUNNER01192.168.0.27Ubuntu 26.04 LTSPython 3.14.4 - the only machine this path needs2 Core4 GB50 GB

Before you start

  1. A module is a file

  2. The guard that stops the body running on import

  3. Where the bytecode went

  4. A package is a directory with __init__.py

  5. Importing from a package

  6. Importing a package does not import its submodules

  7. The three ways to make a module findable

  8. What the exam does with this objective

Official sources