Python Reference Library →

Python super() Function – Call Parent Class Methods

Let’s look at super() function – call parent class methods

  1. Notice

    super() delegates attribute lookup along the method resolution order. It supports cooperative inheritance rather than naming one fixed parent.

  2. Try

    Follow the example, change its sample, and compare what happens.

  3. Check

    Explain the result and test your understanding.

Watch how it works

Focus on how the names, objects, and calculations change. We’ll inspect the printed output in the next section.

Explore the idea

Follow the code and watch its state change. Guided simulation.

Code
Python
class Parent:
    def greeting(self):
        return "Hello"
class Child(Parent):
    def greeting(self):
        return super().greeting() + ", " + 'Ada'
print(Child().greeting())
Live state

Top-level scope

Parent→Object 2
Child→Object 4
Object 2 · typeclass ParentObject 4 · typeclass Child
This step

super() delegates attribute lookup along the method resolution order. It supports cooperative inheritance rather than naming one fixed parent.

Picture super() function – call parent class methods

super() delegates attribute lookup along the method resolution order. It supports cooperative inheritance rather than naming one fixed parent.

Image brief

Alt text
A diagram for Python super() Function – Call Parent Class Methods. Instructions: class Parent: def greeting(self): return "Hello" class Child(Parent): def greeting(self): return super().greeting() + ", " + 'Ada' print(Child().greeting()). Displayed result: Hello, Ada. The final example bindings are Parent --> object 2 (type); Child --> object 4 (type). object 2: class Parent; object 4: class Child
Image generation prompt
Create a clean educational illustration for a Python programming lesson titled "Python super() Function – Call Parent Class Methods". Teaching focus: super() delegates attribute lookup along the method resolution order. It supports cooperative inheritance rather than naming one fixed parent. Depict exactly the relationships and labels in this reference diagram: EXAMPLE INSTRUCTIONS class Parent: def greeting(self): return "Hello" class Child(Parent): def greeting(self): return super().greeting() + ", " + 'Ada' print(Child().greeting()) | v DISPLAYED RESULT Hello, Ada FINAL BINDINGS Parent --> object 2 (type) Child --> object 4 (type) object 2: class Parent object 4: class Child Use a flat vector style, generous spacing, clear arrows and legible labels, with a restrained blue/teal palette on a plain background. The diagram must explain the programming idea accurately. Do not depict variables as boxes containing copied objects when they share a reference. Avoid mascots, decorative screenshots, logos, gradients and extra text. Landscape composition, approximately 3:2, suitable for a course card. Accessible description: A diagram for Python super() Function – Call Parent Class Methods. Instructions: class Parent: def greeting(self): return "Hello" class Child(Parent): def greeting(self): return super().greeting() + ", " + 'Ada' print(Child().greeting()). Displayed result: Hello, Ada. The final example bindings are Parent --> object 2 (type); Child --> object 4 (type). object 2: class Parent; object 4: class Child

Follow the execution

Choose a different sample input, then follow every step through to the output. Before revealing it, predict what the program will display.

Execution workspace

Choose a sample and follow its execution. Guided simulation.

Code
Python
class Parent:
    def greeting(self):
        return "Hello"
class Child(Parent):
    def greeting(self):
        return super().greeting() + ", " + 'Ada'
print(Child().greeting())
Live state

Top-level scope

Parent→Object 2
Child→Object 4
Object 2 · typeclass ParentObject 4 · typeclass Child
This step

The example has finished. Compare the final output with the values and references above.

Terminal
Output
Hello, Ada

What do you expect this program to print?

What does this example display?

class Parent:
    def greeting(self):
        return "Hello"
class Child(Parent):
    def greeting(self):
        return super().greeting() + ", " + 'Ada'
print(Child().greeting())
What does this example display?
Choose one answer. You can try again.

Answer and explanation

Hello, Ada

Follow the printed values in order. The output is: Hello, Ada

Which explanation matches what you learned?

Which explanation matches what you learned?
Choose one answer. You can try again.

Answer and explanation

super() delegates attribute lookup along the method resolution order. It supports cooperative inheritance rather than naming one fixed parent.

super() delegates attribute lookup along the method resolution order. It supports cooperative inheritance rather than naming one fixed parent.

More examples and reference

Python super() Function

The super() function in Python is used to call methods from a parent or superclass. It's commonly used in inheritance to avoid repeating code and make child classes more manageable.

Syntax

super().method_name(arguments)

Parameters:

  • Returns a proxy object that delegates method calls to a parent class.
  • Commonly used inside methods of child classes.

Returns:

  • A temporary object of the superclass that allows you to call its methods.

Why Use super()?

  • To reuse code from a parent class.
  • To avoid hardcoding parent class names (supports clean inheritance).
  • To maintain better support for multiple inheritance.

Example 1: Basic Inheritance

class Parent:
    def greet(self):
        print("Hello from Parent")

class Child(Parent):
    def greet(self):
        super().greet()
        print("Hello from Child")

c = Child()
c.greet()
Hello from Parent
Hello from Child

Example 2: Using super() in __init__()

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

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

d = Dog("Buddy", "Labrador")
print(d.name)
print(d.breed)
Buddy
Labrador

Multiple Inheritance Example

class A:
    def process(self):
        print("A.process()")

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

class C(B):
    def process(self):
        print("C.process()")
        super().process()

c = C()
c.process()
C.process()
B.process()
A.process()

Common Mistakes

  • Calling super() outside a class method will raise an error.
  • Do not forget to call super().__init__() in child constructors to properly initialize inherited attributes.

Interview Tip

super() is frequently tested in OOP interviews to check your understanding of inheritance and code reuse. You may be asked to rewrite code using super() to make it cleaner.

Summary

  • super() helps you access parent class methods.
  • Commonly used in method overriding and constructors.
  • Improves maintainability and supports multiple inheritance.

Practice Problem

Create a class Vehicle with a method start(). Then create a class Car that inherits from Vehicle and overrides start(), but still calls Vehicle.start() using super().

class Vehicle:
    def start(self):
        print("Vehicle started")

class Car(Vehicle):
    def start(self):
        super().start()
        print("Car started")

c = Car()
c.start()

Expected Output:

Vehicle started
Car started

What to remember

Connect what you noticed in the example with the idea below.

Remember

super() delegates attribute lookup along the method resolution order. It supports cooperative inheritance rather than naming one fixed parent.

Watch out for this idea

super() always means the first base class regardless of method resolution order.

This is the misconception to avoid.

Reference checks are optional and do not count toward course progress.

    Reference library →