Python's super() Does Not Call the Parent: It Calls the Next Class

This article explains how super() continues the attribute lookup in the method resolution order of an object's class, how it works in class methods, properties and __init_subclass__, how cooperative methods pass keyword arguments and which errors appear when it is misused.

A green snake coiled over a brown branch among long leaves, its head stretched forward along the branch.
Photo by David Clode on Unsplash

The function super() is usually introduced as the way to call the method of the parent class, and with single inheritance that description gives correct results. Turn-based strategy games offer a more precise image: at the start of a round, the game fixes the order in which every unit acts, and when a unit finishes its action the game passes control to the next unit in that order, not to the unit's commander. This means that super() does not look for the parent written in the class statement; it continues the search in the method resolution order of the object's class, starting after the class in which the call is written. The analogy, however, stops at this point, because a game may change the turn order every round, whereas the method resolution order of a class is fixed when the class is created. The present article examines how super() locates that position, how it behaves in class methods, properties and class creation hooks, how cooperative methods pass arguments along the chain and which errors appear when its assumptions fail. Code written once that adapts to every hierarchy in which it is reused is the secret weapon of super().

The Next Class, Not the Parent

The method resolution order (MRO) of a class lists every class that an attribute lookup visits, as explained in the article devoted to the method resolution order. The call super().method() written inside class C is shorthand for super(C, self).method(): it searches the MRO of type(self) starting after C. The two-argument form makes both ingredients explicit, and the zero-argument form obtains them from a hidden variable that the compiler creates.

class Base:
    def who(self):
        return ["Base"]

class Left(Base):
    def who(self):
        return ["Left"] + super().who()

class Right(Base):
    def who(self):
        return ["Right"] + super().who()

class Child(Left, Right):
    def who(self):
        return ["Child"] + super().who()

child = Child()
print([cls.__name__ for cls in Child.__mro__])  # Output: ['Child', 'Left', 'Right', 'Base', 'object']
print(child.who())                    # Output: ['Child', 'Left', 'Right', 'Base']
print(super(Left, child).who())       # Output: ['Right', 'Base']
print("__class__" in Left.who.__code__.co_freevars)  # Output: True

The call inside Left reaches Right, a class that Left does not know and does not inherit from, because the instance belongs to Child, whose MRO places Right after Left. The expression super(Left, child) reproduces that step by hand and starts the search after Left. The last line shows how the zero-argument form works: the compiler gives every method that mentions super a free variable named __class__, which holds the class where the method was defined, and super() combines it with the first argument of the method.

super() Beyond Instance Methods

The same mechanism works wherever a method receives the class or the instance as its first argument: class methods, properties, which are descriptors, and the hook __init_subclass__, which runs when a subclass is created.

class Shape:
    registry = []

    def __init_subclass__(cls, **kwargs):
        super().__init_subclass__(**kwargs)
        Shape.registry.append(cls.__name__)

    def __init__(self, size):
        self.size = size

    @classmethod
    def unit(cls):
        return cls(1)

    @property
    def area(self):
        return self.size ** 2

class Square(Shape):
    @classmethod
    def unit(cls):
        shape = super().unit()
        shape.label = "unit square"
        return shape

    @property
    def area(self):
        return round(super().area, 2)

square = Square.unit()
print(type(square).__name__, square.label)  # Output: Square unit square
print(Shape.registry)                       # Output: ['Square']
print(Square(1.5).area)                     # Output: 2.25

The class method of Square extends the inherited constructor, and since super().unit() passes cls along, the object created is a Square, not a Shape. The property of the subclass reads the property of the base through super().area, which works because a super object binds descriptors in the same way as an ordinary lookup, the protocol described in the article devoted to descriptors. The hook __init_subclass__ calls super() as well, so that several bases can register the same subclass, a technique compared with metaclasses in the article devoted to metaclasses.

Cooperative Initialization

When several classes in a hierarchy define __init__, each one must call super().__init__ so that the chain reaches every class exactly once. The difficulty lies in the arguments: a class cannot know which class comes next in the MRO of a future subclass, so each class takes the keyword arguments it needs and passes the rest along.

class Model:
    def __init__(self, name, **kwargs):
        super().__init__(**kwargs)
        self.name = name

class Timestamped:
    def __init__(self, created="today", **kwargs):
        super().__init__(**kwargs)
        self.created = created

class Tagged:
    def __init__(self, tags=(), **kwargs):
        super().__init__(**kwargs)
        self.tags = list(tags)

class Article(Model, Timestamped, Tagged):
    pass

article = Article(name="super()", tags=["python"], created="2025-11-29")
print(article.name, article.created, article.tags)  # Output: super() 2025-11-29 ['python']

try:
    Article(name="x", colour="red")
except TypeError as error:
    print(error)  # Output: object.__init__() takes exactly one argument (the instance to initialize)

Each class consumes its own keyword and forwards the remaining ones, so the three initializers run in the order of the MRO and every attribute is set. When an argument reaches the end of the chain without being consumed, object.__init__ rejects it, which turns a misspelled keyword into an immediate error instead of a silent omission. The convention therefore requires keyword arguments throughout the chain, since positional arguments cannot be distributed among classes that do not know one another.

Pitfalls of super()

The behaviour of super() follows from two facts: it depends on the class in which it is written, and it works only for explicit attribute lookups. Six pitfalls are distinguished, which are the following:

  1. Breaking the chain. A class that calls a parent directly, such as Base.__init__(self), skips every class between them in the MRO.
  2. Incompatible signatures. A method that passes positional arguments, or none, to super() fails when the next class in a subclass's MRO expects others.
  3. Functions defined outside the class. The zero-argument form needs the __class__ cell that the compiler creates only inside a class body, so a function attached later fails.
  4. Implicit lookups. Operators and statements, such as super()[i] or len(super()), do not go through super; the explicit method, super().__getitem__(i), must be called instead.
  5. Assignment. super() supports reading attributes, not setting them; super().x = 1 raises AttributeError.
  6. Leftover arguments. A keyword that no class consumes reaches object.__init__ and raises TypeError.

The third and fourth pitfalls are reproduced in the following example.

class Base:
    def greet(self):
        return "hello"

    def __getitem__(self, index):
        return index * 2

def greet(self):
    return super().greet().upper()

class Child(Base):
    def item(self):
        return super()[3]

    def explicit_item(self):
        return super().__getitem__(3)

Child.greet = greet
try:
    Child().greet()
except RuntimeError as error:
    print(error)  # Output: super(): __class__ cell not found

try:
    Child().item()
except TypeError as error:
    print(error)  # Output: 'super' object is not subscriptable
print(Child().explicit_item())  # Output: 6

The function greet was compiled outside any class, so it has no __class__ cell, and the zero-argument call cannot know where to start; the two-argument form, super(Child, self), would work. The subscription fails because indexing looks up __getitem__ on the type of the super object, whereas the explicit call goes through the attribute lookup that super implements.

Choosing How to Call Inherited Code

Consequently, the right form depends on whether the hierarchy may grow and on where the code is written, as the following table summarizes.

Situation Recommended approach
Extending a method in single or multiple inheritance super().method(...)
Several classes in a hierarchy define __init__ Cooperative super().__init__(**kwargs) in every class
A function defined outside the class body super(Class, self) with explicit arguments
Calling one specific ancestor on purpose Ancestor.method(self), documented as a deliberate exception
Special methods of the parent super().__getitem__(...), never operators on super()
Extending a property or class method super().attribute or super().classmethod()

Conclusion

It is concluded that super() returns a proxy that continues the attribute lookup in the method resolution order of the object's class, after the class in which the call is written, and that this design makes the same line of code reach different classes depending on the hierarchy in which it runs. This magic requires every class in the chain to cooperate, with compatible keyword arguments and explicit method calls, and it relies on the __class__ cell that only a class body provides. The first method that runs when an instance is created, __new__, also delegates to its parents through super() and is developed in a future article of this series.