Python Developer Interview Question

How does Python decide which method to call with multiple inheritance?

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

Python computes a method resolution order using the C3 linearization, which preserves each class own order of bases and guarantees a subclass appears before its parents. Attribute lookup walks that list and takes the first match. You can inspect it with the mro method, and super follows the MRO of the actual instance, not just the immediate parent class.

Why interviewers ask this

Mixins are everywhere in Django and DRF, so interviewers want to know you can predict which implementation wins and debug it when a mixin silently overrides something. The real signal is understanding that super is not a synonym for parent; it is the next class in the MRO of the instance. That misunderstanding is the root of most cooperative inheritance bugs people spend afternoons on.

How to structure your answer

  • Name C3 linearization and what it guarantees.
  • Say lookup takes the first match in that order.
  • Correct the common misreading of super.
  • Mention how you inspect the MRO in practice.

Example answer

Spoken example, first person

Python builds a linear ordering of the class and all its ancestors using C3, then attribute lookup walks that list top to bottom and stops at the first hit. C3 guarantees two things: a class always comes before anything it inherits from, and the relative order you wrote your bases in is preserved. If those constraints cannot both be satisfied, the class definition itself raises a TypeError at import time, which is a nice property because you find out immediately rather than at runtime. The part I make sure to say is that super does not mean parent. It means the next entry after the current class in the MRO of the instance, which is why a mixin calling super can land on a sibling class it never inherited from. That is the whole basis of cooperative multiple inheritance in Django class based views. When something surprising happens I print the mro list, and the answer is usually obvious within seconds because the mixin order in the class statement was backwards.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • What happens if C3 cannot produce a consistent order?
  • Why do Django mixins go before the base view class?
  • How does super behave inside a class method?

Related python developer questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot