Logo

Question preview

Ouroboros 2

What this preview is

About this preview

Ouroboros 2 is a hard quant interview question on language knowledge in Python.

Unlock full access to getcracked

Join to unlock this question, detailed solutions, and our complete library of quant finance interview prep.

Understanding Python module execution and import mechanics

This is a hard-difficulty question that tests your grasp of how Python's module system behaves when code is executed via the -m flag. It requires you to trace through import resolution, namespace setup, and the distinction between script and module execution contexts.

To solve problems like this, you need to reason carefully about what __name__ resolves to, how relative and absolute imports are resolved, and which code actually runs at different stages of module initialization. The question rewards close reading of the provided snippet and mental execution of the import sequence—small details in how packages and modules are structured can change the output entirely.

  • The -m flag and its effect on __name__ and __package__
  • Import order and module caching
  • Circular imports and lazy evaluation
  • Differences between package initialization and script execution