PCAP Modules and Packages Practice Question
During development, a programmer modifies a module that is already imported in the current Python session. To see the changes without restarting the interpreter, which function from the importlib module should be called?
⚠ Common exam trap
Python Institute often tests the distinction between the Python 2 built-in `reload()` and the Python 3 `importlib.reload()` syntax, and candidates mistakenly choose the bare `reload()` option without realizing it is no longer a built-in function.
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
✓
importlib.reload()
`importlib.reload()` is the official Python function to re-import a previously imported module, applying any changes made to its source code without restarting the interpreter. It is part of the `importlib` module and is the recommended way to reload modules in Python 3.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
reload()
Why it's wrong here
In Python 3, the built-in reload() function was removed from the builtins namespace. Calling plain reload() thus raises NameError, as it is no longer a built-in. Historically, in Python 2, reload() was built-in, but starting Python 3, it must be accessed via importlib.reload().
- ✗
reload_module()
Why it's wrong here
There is no function named reload_module() in importlib or anywhere in the standard library. The correct API is importlib.reload(). It might be confused with importlib.import_module(), but that's a different function for importing, not reloading. So this option is invalid because it references a nonexistent function.
- ✓
importlib.reload()
Why this is correct
This is the correct way to reload a module in Python 3. It takes a module object (already imported) and re-executes its source code, updating the module's attributes in place. It is particularly useful during development to pick up changes without restarting the interpreter. Note that it returns the updated module object, and other references to the old module still point to the same object (since it mutates in place).
- ✗
importlib.import_module()
Why it's wrong here
This function imports a module by name, returning the module object. It does not reload an already imported module; if the module is already in sys.modules, it just returns it without re-executing. For re-reading source code, you need importlib.reload() instead. So it's wrong because it doesn't force a reload.
Go deeper
Related to this question
About these practice questions
Courseiva writes every PCAP question from scratch — 169 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 →
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.