super/MRO, Python's most misunderstood feature.

mCoding · 239K views · 2022 · 21:07

Open on YouTube

Python, Ruby & scripting languagesProgramming language designexplainer

Why Stack Overflow recommends it

Stack Overflow users link it when someone is confused about what super() does with inheritance, constructors and the MRO.

Recommended by 1 people across 1 different months, 2022 to 2025.

What it is

mCoding explains how Python's super() really works, showing that it follows the Method Resolution Order rather than simply calling a parent class. It covers single and multiple inheritance, how super uses stack frame inspection and object proxying, and ends with a pure Python reimplementation of super.

What people said

Recommends MangoNrFive · 2022-07 · Stack Overflow · on “What does *arg and **kwargs mean when passed through a constructor?”

I can recommend you this video that helped me a lot in understanding how super works super, Python's most misunderstood feature. [this video]

Cites binds · 2022-05 · Stack Overflow · on “How do I access an attribute from a parent class in Python?”

Welcome to Stack Overflow. It seems like you don’t quite understand what inheritance is. Here is a quick “deep” dive. What is inheritance in OOP? Inheritance is a fundamental concept in object oriented programming. It is when you provide a base or super class for another class. The super class usually contains functionality that will apply, or be useful, to any instance of the classes deriving from it. It prevents you from having to reimplement things. Inheritance in Python In Python, a class deriving from another class automatically is able to access methods and attributes defined in super class, through the super() function: class Foo: def bar(self): print("bar") class Bar(Foo): def bar(se

Cites Stephen Skett · 2025-04 · Stack Overflow · on “Method Resolution Order (MRO) with mypy type check?”

For my money, this is an incorrect use of super (from a static-typing point of view), and MyPy is right to raise an error. Yes, if you only ever plan to use class B as a mixin-class with A (or an equivalent class) as its sibling, this setup can be used without causing any errors at runtime - as long as B is declared before A (or equivalent) in the inheritance-hierarchy.* However, consider the situation where an instance of B is itself created: B().method(0) would be poorly-defined in this case, as there is no super-class (other than object ) where the super -call can expect to find method(i) , and this WOULD result in an AttributeError at runtime. As MyPy is a STATIC type-checking tool, it i