What this Python inheritance and method-resolution interview question tests
This is a medium-difficulty Python question designed to assess your understanding of method resolution order (MRO) and how inheritance chains work in Python. It's the kind of question interviewers use to distinguish between candidates who have read the documentation and those who rely on intuition alone.
To solve it, you need to trace through a code snippet that involves class hierarchies, understand which method gets called at each step, and predict the output or identify whether an error occurs. The question rewards careful reading and a mental model of how Python resolves method calls through parent classes and special methods.
- Method Resolution Order (MRO) and the C3 linearization algorithm
- super() and cooperative multiple inheritance
- Attribute and method lookup in class hierarchies
- Common pitfalls with attribute binding and scope