Last modified: Nov 19, 2026

Python super() Function Explained

The super function is a built-in tool in Python. It lets a child class call methods from its parent class. This is a core part of object-oriented programming in Python.

Many beginners find super() confusing at first. But it is simple once you see it in action. This guide walks you through the basics with clear examples.

What Is the super Function?

The super function returns a temporary object of the parent class. You use it to call parent methods from inside a child class.

This helps you avoid hardcoding the parent class name. It also makes your code work well with multiple inheritance.

Here is the basic syntax:


super().method_name(arguments)

Inside a class method, super() with no arguments is the most common form. Python figures out the rest for you.

Why Do We Need super()?

Imagine you have a parent class and a child class. The child class wants to reuse the parent logic and add its own behavior.

You could call the parent method directly by name. But that breaks if the class name changes. It also causes problems with multiple inheritance.

The super() function solves both issues. It follows the method resolution order (MRO) automatically.

If you are new to inheritance, think of it like a family tree. The child inherits traits from the parent. The super function is the child asking the parent for help.

A Simple Example

Let's start with a basic parent and child class.


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

    def speak(self):
        return f"{self.name} makes a sound."


class Dog(Animal):
    def __init__(self, name, breed):
        # Call the parent __init__ method
        super().__init__(name)
        self.breed = breed

    def speak(self):
        # Call the parent speak method
        base = super().speak()
        return f"{base} Specifically, {self.name} barks."


dog = Dog("Rex", "Labrador")
print(dog.name)
print(dog.breed)
print(dog.speak())

Rex
Labrador
Rex makes a sound. Specifically, Rex barks.

Notice how the child class reuses the parent logic. The __init__ method sets the name through the parent. The speak method builds on the parent result.

This is clean and avoids repeating code. It also keeps the parent as the single source of truth.

How super() Works with Multiple Inheritance

Python supports multiple inheritance. A class can have more than one parent. This is where super() really shines.

The super function follows the MRO. The MRO is the order Python uses to look up methods.

You can check it with the mro method or the __mro__ attribute. This is closely related to how object identity works, which you can explore in this guide on the Python id function and object identity.

Here is a classic diamond example:


class A:
    def greet(self):
        return "Hello from A"


class B(A):
    def greet(self):
        return "Hello from B -> " + super().greet()


class C(A):
    def greet(self):
        return "Hello from C -> " + super().greet()


class D(B, C):
    def greet(self):
        return "Hello from D -> " + super().greet()


d = D()
print(d.greet())
print(D.__mro__)

Hello from D -> Hello from B -> Hello from C -> Hello from A
(, , , , )

Look at the output. The call chain follows the MRO exactly. Each super() call moves to the next class in line.

Without super(), class B would call A directly. Then C would also call A. Class A would run twice. That is a common bug.

This cooperative pattern is powerful. It lets each class do its part and pass control along.

Using super() in Class Methods and Static Methods

The super function works in regular methods too, not just __init__. You can also use it with class methods.


class Base:
    @classmethod
    def describe(cls):
        return f"Base class: {cls.__name__}"


class Child(Base):
    @classmethod
    def describe(cls):
        # Call parent classmethod
        parent = super().describe()
        return parent + " | Child class adds detail"


print(Child.describe())

Base class: Child | Child class adds detail

This pattern is useful for factory methods and shared setup logic. The child extends behavior without copying code.

Common Mistakes with super()

There are a few traps to watch for. Here are the most common ones.

Mistake 1: Forgetting to call super().__init__(). If the parent sets important attributes, the child must call the parent initializer. Otherwise those attributes never get created.

Mistake 2: Using the wrong argument order. The old two-argument form is super(ClassName, self). Mixing this up causes errors. In modern Python, just use super() with no arguments.

Mistake 3: Assuming super() calls only the direct parent. It does not. It follows the MRO. In multiple inheritance, the next class may not be the direct parent.

These mistakes cause confusing bugs. Reading the MRO often reveals the problem quickly.

super() vs Direct Parent Calls

Some developers write ParentClass.method(self) instead of using super(). This works in simple cases but is fragile.

If you rename the parent class, every direct call breaks. If you change the inheritance order, direct calls skip classes.

The super() function avoids both problems. It adapts to the class hierarchy at runtime.

For single inheritance, both styles behave the same. For multiple inheritance, super() is the correct choice.

If you want to compare styles of writing functions, this article on Python lambda vs function key differences is a helpful read.

Practical Use Case: Extending a Library Class

You often use super() when extending third-party classes. For example, you might extend a form class or a view class.


class Logger:
    def log(self, message):
        print(f"[LOG] {message}")


class TimestampLogger(Logger):
    def log(self, message):
        # Add a prefix, then reuse parent logging
        super().log(f"[{self.__class__.__name__}] {message}")


logger = TimestampLogger()
logger.log("Application started")

[LOG] [TimestampLogger] Application started

The child adds context but keeps the parent formatting. This is the cooperative style that super() encourages.

This approach also works well with decorators and mixins. You can chain behavior without rewriting core logic.

super() and the object Base Class

Every class in Python inherits from object. The MRO always ends with object.

When your super() call reaches object, it stops. Methods like __init__ on object accept no extra arguments. That is why passing extra arguments up the chain can fail.

This is a subtle but important detail. It explains many "takes no arguments" errors in multiple inheritance.

If you want to dig into related iteration tools, this guide on Python generators and yield explained shows how classes and iterators connect.

Quick Reference Summary

Here is a short checklist for using super() correctly:

Use super() with no arguments inside instance methods.

Use super() inside __init__ to set up parent attributes.

Use it in class methods to extend parent behavior.

Always check the MRO when debugging multiple inheritance.

Prefer super() over direct parent calls for flexibility.

Conclusion

The super() function is a small tool with a big role. It connects child classes to parent classes in a clean, flexible way.

Start with the simple single-inheritance examples. Then try the diamond pattern. Watch the MRO output and trace each call.

Once you understand super(), your Python classes become easier to extend and maintain. It is one of the most useful built-ins for any object-oriented programmer.