
Answer-first summary for fast verification
Answer: `sys.path`
The correct answer is **sys.path**. In Python, `sys.path` is a list of strings that determines the interpreter's search path for modules. When an `import` statement is executed, Python looks for the module in the directories listed in `sys.path` in sequential order. This list is typically initialized from the environment variable `PYTHONPATH` along with installation-dependent defaults. * **sys.path**: The standard list used by the interpreter to resolve module imports at runtime. It can be modified dynamically to include new search directories. * **os.path**: This is a module containing functions for manipulating filesystem paths (e.g., `join`, `split`, `exists`), but it has no role in the module import mechanism. * **importlib.resource_path**: While `importlib` is the engine behind the import system, `resource_path` (and similar utilities) is generally used for accessing non-code resource files within a package. * **pypi.path**: This is not a standard Python variable or module; PyPI is the Python Package Index repository, not a local search path variable.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
Which Python variable contains the list of strings that specifies the search path for modules, determining which directories the interpreter searches to locate required modules?
A
os.path
B
pypi.path
C
sys.path
D
importlib.resource_path