Question 311 of 511
Modules and PackageshardMultiple ChoiceObjective-mapped

Quick Answer

The correct answer is Python’s module caching in sys.modules, which prevents re-loading the modified source. When a module like submod.py is imported, Python stores the resulting module object in the sys.modules dictionary; any subsequent import of the same module simply retrieves the cached object without re-executing the file. This means that even after editing submod.py, the interpreter continues to use the stale version from sys.modules unless the module is explicitly reloaded with importlib.reload() or the session is restarted. On the PCAP exam, this question tests your understanding of Python’s import system and the common pitfall of assuming source changes automatically propagate—a trap many developers fall into during development with egg-link installs. A reliable memory tip: think of sys.modules as a “sticky note” that holds the first version forever; you must tear it off (reload) to see updates.

PCAP Modules and Packages Practice Question

This PCAP practice question tests your understanding of modules and packages. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

A package 'pkg' is installed as an egg-link in development mode. Inside the package, there is a module 'submod.py' that uses relative imports. When a developer modifies 'submod.py', they find that changes are not always reflected on import. What is the most likely reason?

Clue words in this question

Noticing these words before you look at the options changes how you read each choice.

  • Clue: "most likely"

    Why it matters: Probability qualifier — the question wants the most probable cause or outcome, not a guaranteed one. Eliminate low-probability options.

  • Clue: "always"

    Why it matters: Absolute qualifier. An answer using 'always' is only correct if there are genuinely no exceptions — absolute statements are often wrong in networking.

Question 1hardmultiple choice
Full question →

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

Python's module caching in sys.modules prevents re-loading the modified source.

Option C is correct because Python caches imported modules in `sys.modules`. When a module is imported, Python stores the module object in `sys.modules` and subsequent imports retrieve it from this cache without re-executing the module's code. Modifying the source file of `submod.py` does not automatically invalidate this cache, so the changes are not reflected unless the module is explicitly reloaded (e.g., with `importlib.reload()`) or the interpreter is restarted.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Answer analysis

Option-by-option breakdown

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

  • The sys.path is altered by the egg-link, causing a different module to be loaded.

    Why it's wrong here

    The egg-link ensures the development directory is used; but once loaded, it's cached.

  • Relative imports are cached in the __init__.py file.

    Why it's wrong here

    No such caching.

  • Python's module caching in sys.modules prevents re-loading the modified source.

    Why this is correct

    When using egg-link, the module is loaded once; subsequent imports use cached version unless explicitly reloaded.

    Clue confirmation

    The clue words "most likely", "always" in the question point toward this answer.

    Related concept

    Read the scenario before looking for a memorised answer.

  • The __pycache__ directory is not cleared automatically.

    Why it's wrong here

    Bytecode cache can be stale but Python checks source file timestamp; still reloads if newer.

Common exam traps

Common exam trap: answer the scenario, not the keyword

Python Institute often tests the distinction between source file modification and module caching, where candidates mistakenly think the issue is with bytecode caching (`__pycache__`) or path resolution, rather than the `sys.modules` cache that prevents re-execution of the module's code.

Detailed technical explanation

How to think about this question

When a module is imported, Python first checks `sys.modules`; if found, it returns the cached module object without re-reading the source file. This is by design for performance and to maintain singleton behavior. In development mode with egg-links, the source is editable, but the developer must either restart the interpreter or use `importlib.reload()` to see changes. A subtle behavior: even `importlib.reload()` does not re-run top-level code in submodules that were imported via relative imports if the parent package is already cached—this can lead to stale references.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A media company stores terabytes of video archives that are accessed once a year for audit purposes. Moving these objects to a cold storage tier (Azure Archive, S3 Glacier, or Google Nearline) costs a fraction of hot storage. Questions like this test whether you understand storage tiers, access frequency tradeoffs, and retrieval latency requirements.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related PCAP practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free PCAP practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this PCAP question test?

Modules and Packages — This question tests Modules and Packages — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: Python's module caching in sys.modules prevents re-loading the modified source. — Option C is correct because Python caches imported modules in `sys.modules`. When a module is imported, Python stores the module object in `sys.modules` and subsequent imports retrieve it from this cache without re-executing the module's code. Modifying the source file of `submod.py` does not automatically invalidate this cache, so the changes are not reflected unless the module is explicitly reloaded (e.g., with `importlib.reload()`) or the interpreter is restarted.

What should I do if I get this PCAP question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Are there clue words in this question I should notice?

Yes — watch for: "most likely", "always". Probability qualifier — the question wants the most probable cause or outcome, not a guaranteed one. Eliminate low-probability options.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 30, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

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.