What this Python import and namespace question tests
This medium-difficulty question probes your understanding of how Python's module system and namespace resolution work. It's the kind of question quant firms ask to confirm you can predict code behaviour without running it—a critical skill when debugging or reasoning about system interactions under pressure.
The question requires you to trace how modules are loaded, how names are bound in different scopes, and what happens when code is executed at import time versus runtime. A clean answer demonstrates familiarity with Python's execution model, the import machinery, and the distinction between module-level and local namespaces.
- Module initialization and
__name__ attribute - Top-level code execution during import
- Namespace lookup and binding order
- Side effects of import statements