Python super()

Learn how Python super() works with inheritance. See how to use super().__init__() in child classes, call parent methods, understand MRO, and avoid common multiple inheritance mistakes.

Published

Updated

Read time 6 min read

Reviewed byDeepak Prasad

Python super()

Use super() inside a class to call methods from the next class in Python's method resolution order (MRO). The most common pattern is super().__init__() in a child class constructor.

In simple inheritance, super() usually calls the immediate parent. In multiple inheritance, super() follows the MRO—the next class in that order, not necessarily a direct parent. Python's official docs describe super() as returning a proxy for cooperative delegation, especially in multiple inheritance.

Tested on: Python 3.13.3; kernel 6.14.0-37-generic.


Python super() quick reference

Task Use
Call parent initializer super().__init__(args)
Call parent method super().method_name(args)
Extend overridden method super().method_name() inside child method
Check method lookup order ClassName.mro() or ClassName.__mro__
Python 3 recommended form super()
Older explicit form super(CurrentClass, self)
Multiple inheritance behavior Follows MRO
Avoid hard-coding parent class Use super()

What is super() in Python?

  • super() is a built-in function.
  • It returns a proxy object.
  • That proxy delegates method calls to the next class in the MRO.
  • It is mainly used with inheritance.
  • It avoids hard-coding the parent class name in every call.

You typically write super() with no arguments inside a class method in Python 3.


Why use super()?

super() helps you:

  • Run parent initialization logic from a child __init__()
  • Reuse parent methods instead of duplicating code
  • Extend an overridden method rather than replace it entirely
  • Keep code maintainable when class names change
  • Support cooperative multiple inheritance when every class in the chain calls super()

super() is useful, but not required in every class—only when you need parent setup or shared behavior.


Python super().init() example

When a child defines its own __init__(), call super().__init__() so parent attributes are initialized, then set child-specific fields. The Python constructor guide explains __init__ parameters, defaults, and validation on both parent and child sides.

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


class Employee(Person):
    def __init__(self, name, employee_id):
        super().__init__(name)
        self.employee_id = employee_id


employee = Employee("Alice", 101)
print(employee.name)
print(employee.employee_id)
Output

The output is Alice and 101. Parent logic runs first; the child adds employee_id.


What happens if you do not call super().init()?

If the child defines __init__() and skips super().__init__(), the parent initializer does not run automatically:

python
class Parent:
    def __init__(self):
        self.ready = True


class Child(Parent):
    def __init__(self):
        self.extra = 1


child = Child()
print(child.extra)

try:
    print(child.ready)
except AttributeError as e:
    print(e)
Output

The first print succeeds (1), but child.ready raises AttributeError because Parent.__init__() never ran.

Always call super().__init__(...) when the parent constructor sets up state the child relies on.


Call a parent method using super()

super() is not limited to __init__(). Call any parent method when the child extends behavior:

python
class Vehicle:
    def describe(self):
        return "Vehicle"


class Car(Vehicle):
    def describe(self):
        base = super().describe()
        return f"{base} with four wheels"


print(Car().describe())
Output

The output is Vehicle with four wheels.


Method overriding with super()

Overriding means defining a method in the child with the same name as in the parent.

  • Use super().method() when you want parent behavior plus child additions.
  • Replace the method entirely when parent behavior should not run.
python
class Animal:
    def speak(self):
        return "..."


class Dog(Animal):
    def speak(self):
        return super().speak() + " bark"


print(Dog().speak())
Output

You get ... bark.


super() in single inheritance

With one parent class, super() usually calls that parent's method—the easiest mental model for beginners.

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


class Student(Person):
    def __init__(self, name, age, student_id):
        super().__init__(name, age)
        self.student_id = student_id


student = Student("Bob", 20, "S-42")
print(student.name, student.age, student.student_id)
Output

Output: Bob 20 S-42.


super() and multiple inheritance

With multiple inheritance, super() does not simply mean “call the parent.” It calls the next class in the MRO.

For cooperative design, each class should call super().__init__() with a compatible signature so initialization flows once through the diamond without duplicating base setup.

python
class A:
    def __init__(self):
        print("A init")


class B(A):
    def __init__(self):
        print("B init")
        super().__init__()


class C(A):
    def __init__(self):
        print("C init")
        super().__init__()


class D(B, C):
    def __init__(self):
        print("D init")
        super().__init__()


D()
Output

Output order: D init, B init, C init, A initA runs once, not twice.

Hard-coding A.__init__(self) from both B and C would risk double initialization of A.


Method Resolution Order, or MRO

The MRO is the order Python searches for methods and attributes. super() follows this order.

Inspect it with ClassName.mro() or ClassName.__mro__:

python
class A:
    pass

class B(A):
    pass

class C(A):
    pass

class D(B, C):
    pass

print(D.mro())
Output

You see [D, B, C, A, object] — read left to right as the lookup order.


super() vs parent class name

Approach Example Notes
super() super().__init__() Recommended in modern Python 3
Parent class name Parent.__init__(self) Works in simple cases but hard-codes the parent
Explicit super form super(Child, self).__init__() Older Python 2 style; still valid but rarely needed in Python 3

Prefer super() unless you have a specific reason to name the parent explicitly.


super().init() with arguments

Pass required parent arguments through super().__init__():

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


class Employee(Person):
    def __init__(self, name, age, department):
        super().__init__(name, age)
        self.department = department


emp = Employee("Carol", 30, "Engineering")
print(emp.name, emp.department)
Output

The child accepts extra arguments while forwarding shared ones to the parent. In multiple inheritance, keep __init__ signatures compatible across cooperating classes.


Can super() access parent variables?

Clarification for beginners:

  • Use super() to call methods (including __init__).
  • After super().__init__() runs, access instance attributes with self.name, self.age, and so on—they were created on self during parent initialization.
  • super().some_attribute is not the usual pattern for normal instance fields.
python
class Parent:
    def __init__(self):
        self.count = 0


class Child(Parent):
    def __init__(self):
        super().__init__()
        self.count += 1


c = Child()
print(c.count)
Output

Output is 1. Use self.count, not super().count, for typical instance data.


Common mistakes with super()

  1. Forgetting parenthesessuper.__init__ instead of super().__init__().
  2. Skipping super().__init__() in a child __init__() when parent setup is required.
  3. Wrong arguments to super().__init__(...).
  4. Assuming super() always means direct parent — in multiple inheritance it follows MRO.
  5. Hard-coding Parent.__init__(self) in diamond hierarchies — can duplicate base initialization.
  6. Calling both Parent.__init__(self) and super().__init__() — risk double initialization.
  7. Incompatible __init__ signatures in cooperative multiple inheritance.
  8. Misspelling super() as supper() — not a built-in function.
  9. Using super() outside a method without the two-argument form — super() with no args only works inside a class method.

Summary

super() delegates to the next class in the MRO. Use super().__init__() to initialize parent state in child constructors. Use super().method() to extend overridden methods. In single inheritance, super() usually behaves like calling the parent. In multiple inheritance, it follows the MRO and works best when all classes cooperate with consistent super() calls. For the broader class syntax that makes inheritance possible, start with the Python class example tutorial.

Useful references


Frequently Asked Questions

1. What does super() do in Python?

super() returns a proxy that delegates method calls to the next class in the method resolution order. It is commonly used as super().init() in child class constructors.

2. Why should I use super().__init__() in a child class?

If the child defines its own init(), the parent init() does not run automatically. super().init() runs the next initializer in the MRO so parent attributes are set up.

3. Does super() always call the direct parent class?

In single inheritance, super() usually calls the immediate parent. In multiple inheritance, super() follows the MRO, which may skip to a sibling class rather than a direct parent.

4. What is the difference between super() and Parent.__init__(self)?

super() is the modern recommended form and follows the MRO. Parent.init(self) hard-codes the parent name and can break cooperative multiple inheritance.

5. Can super() call methods other than __init__()?

Yes. Use super().method_name() inside an overridden method to reuse parent behavior and extend it.

6. What happens if I forget super().__init__()?

Parent initialization may not run, so attributes created in the parent init() can be missing and raise AttributeError when accessed.
Bashir Alam

Data Analyst and Machine Learning Engineer

Computer Science graduate from the University of Central Asia, currently employed as a full-time Machine Learning Engineer at uExel. His expertise lies in OCR, text extraction, data preprocessing, and …