Courseiva
Modules and Packages →mediumMultiple Select

PCAP Modules and Packages Practice Question

Which TWO statements about namespace packages are true?

⚠ Common exam trap

Python Institute often tests the misconception that all packages require an __init__.py file, but namespace packages are a deliberate exception introduced in Python 3.3, and candidates may incorrectly assume that any directory with .py files automatically becomes a namespace package.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

They are supported in Python 3.3 and later.

Namespace packages were introduced in Python 3.3 via PEP 420. They allow a package to be split across multiple directories on sys.path without requiring an __init__.py file, enabling logical grouping of subpackages from different locations.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    They are automatically created when a directory containing .py files is added to sys.path.

    Why it's wrong here

    Merely adding a directory containing .py files to sys.path does not automatically create a namespace package. A directory without __init__.py can indeed be imported as a namespace package, but this happens at import time, not as a side effect of modifying sys.path. Furthermore, whether a namespace package is formed depends on the import system finding one or more matching portions, not on the presence of .py files in the directory.

  • ✓

    They are supported in Python 3.3 and later.

    Why this is correct

    Namespace packages were introduced in Python 3.3 via PEP 420, which rewrote the import machinery to allow packages to exist without an __init__.py file. Before that release, every package had to contain __init__.py, and a directory without it was not importable as a package. Therefore, the namespace package concept is supported only in Python 3.3 and later.

  • ✓

    They allow a single package to be distributed across multiple directories.

    Why this is correct

    A key property of namespace packages is that multiple directories listed on sys.path can contribute modules and subpackages to the same package name. Because there is no __init__.py to be loaded once and bind the package to a single location, the import system aggregates all matching directory portions in sys.path order. This allows one logical package to be spread across separate directories, network-mounted filesystems, or even different installation prefixes.

  • ✗

    They can only contain __init__.py files.

    Why it's wrong here

    This claim is doubly wrong: namespace packages deliberately have no __init__.py, and they are not limited to containing only that file. In fact, a namespace package can hold any number of Python modules, nested subpackages, and data files, exactly like a regular package. The absence of __init__.py is what enables multiple directories to merge, but it imposes no restriction on the kinds of files the directories may contain.

  • ✗

    They require an __init__.py file.

    Why it's wrong here

    If a directory contains an __init__.py, the import system classifies it as a regular package, not a namespace package. Namespace packages were designed specifically to make __init__.py optional, which allows different directories to share a package name without any single file claiming ownership. Thus, requiring an __init__.py would contradict the very definition of a namespace package and would actually disable the feature.

About these practice questions

Courseiva writes every PCAP question from scratch — 421 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This PCAP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCAP exam.