Python super() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
Built-in type

Definition

In Python, super() returns a proxy object that forwards method calls to the next class in the method resolution order (MRO), which for simple inheritance is the parent class. The most common use is super().__init__(...) to run the parent's setup in a subclass.

With multiple inheritance, β€œnext” follows the MRO, not just the first parent, so every class in a diamond is called exactly once when each one uses super(). Inside a method, the zero-argument form super() works automatically; super(Class, obj) is the explicit form.

super is a built-in type (a class) that you call like a function: each call creates a new super object. Like every built-in, it lives in the builtins module and is always available without an import.

Syntax

Call it inside a method, then call the method you want on the result.

python
class Child(Parent):
    def __init__(self, x, y):
        super().__init__(x)
        self.y = y
CallWhat it does
super().__init__(...)Runs the parent's initializer.
super().method()Calls the overridden parent version.
super(Child, self)Explicit form, same as super() in a method.
Child.__mro__Shows the order super() follows.

super() is a built-in type you call like a function; the zero-argument form only works inside a method defined in a class body.

Library declarations
python
super()
super(type, object_or_type=None, /)
# class super: a proxy that follows the MRO

Parameters

ParameterDescription
typeOptional. The class to start searching after. Filled in automatically inside methods.
object_or_typeOptional. The instance (or class) to bind to, usually self.

Return Value

Return ValueDescription
superA proxy object; attribute lookups on it go to the next class in the MRO.

Python Examples

Example 1 — Extend __init__ and a Method

Reuse the parent's initializer and build on its speak() method.

python
class Animal:
    def __init__(self, name):
        self.name = name

    def speak(self):
        return self.name + " makes a sound"


class Dog(Animal):
    def __init__(self, name, breed):
        super().__init__(name)
        self.breed = breed

    def speak(self):
        return super().speak() + " (woof)"


rex = Dog("Rex", "beagle")
print(rex.name, rex.breed)
print(rex.speak())

How It Works

  1. Shared setup. super().__init__(name) lets Animal set self.name.
  2. Add your own. Dog then stores the extra breed attribute.
  3. Extend, not replace. Dog.speak calls the parent version and appends to its result.
  4. No class names hard-coded. Writing super() instead of Animal keeps working if the hierarchy changes.

Example 2 — super() Follows the MRO in a Diamond

Chain super() calls through two parents that share a base class.

python
class Base:
    def hello(self):
        return ["Base"]


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


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


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


print(Child().hello())
print([cls.__name__ for cls in Child.__mro__])

How It Works

  1. Next in line, not parent. Inside Left, super() goes to Right, because that is next in Child's MRO.
  2. Each class once. Base runs a single time even though both Left and Right inherit from it.
  3. MRO order. __mro__ shows Child, Left, Right, Base, object, the order super() walks.
  4. Cooperative design. This works because every class calls super().

Example 3 — Customize a dict with super()

Lowercase keys on assignment, then use the explicit two-argument form.

python
class LowerKeys(dict):
    def __setitem__(self, key, value):
        super().__setitem__(key.lower(), value)


d = LowerKeys()
d["Name"] = "Ana"
d["CITY"] = "Oslo"
print(d)
print(d["name"], "Name" in d)
print(super(LowerKeys, d).__getitem__("city"))

How It Works

  1. Override one method. Only __setitem__ changes; everything else is ordinary dict behaviour.
  2. Delegate the storage. super().__setitem__ does the real work with the lowercased key.
  3. Original keys are gone. "Name" was stored as "name", so "Name" in d is False.
  4. Explicit form. super(LowerKeys, d) works outside the class and calls dict's own __getitem__.

Frequently Asked Questions

It gives access to methods of the next class in the method resolution order, usually the parent, so you can extend them.
To run the parent class's initializer so its attributes are set up before you add your own.
The method resolution order: the sequence of classes Python searches for attributes. See it with ClassName.__mro__.
super() follows the MRO, so it works correctly with multiple inheritance and does not hard-code the parent's name.
Not in Python 3 inside a method: super() is enough. super(Class, self) is the older explicit form.

Next: tuple()

Build an immutable sequence from an iterable.

tuple() →

About the author

Mari Selvan M P
Mari Selvan M P πŸ”—

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful