Loading…
A short voice session: one question, one follow-up, then instant feedback — up to 5 minutes.
Python uses the C3 linearization to build the Method Resolution Order (MRO); super() calls the next class in the MRO of the instance's type, not necessarily the direct parent.
Every class has an MRO, visible through ClassName.mro, that lists the order in which classes are searched for attributes. C3 linearization keeps subclasses before their bases and preserves the order bases were listed. super().method() looks up the method in the class that comes after the current one in the MRO of type(self), which is what makes cooperative multiple inheritance and mixins work, as long as every class calls super() consistently and accepts **kwargs where signatures differ. In a diamond hierarchy this guarantees the shared base is called only once. Deep multiple inheritance is still hard to reason about, so composition is often preferred.