How do I call a parent class's method from a child class in Python?

Calling a Parent Class's Method from a Child Class in Python

In Python, you can call a parent class's method from a child class using either the super() function or the parent class name directly. Here's how each approach works:

Using super()

The super() function is the most common and Pythonic way to call a method from the parent class. It automatically finds the parent class in the method resolution order (MRO) and calls the method.

Example:

class Parent: def greet(self): print("Hello from Parent") class Child(Parent): def greet(self): super().greet() # Calls the parent class's method print("Hello from Child") # Usage child = Child() child.greet()

Output:

Hello from Parent
Hello from Child

Explanation:

  • super().greet() calls the greet method from the Parent class.
  • After the parent class's method is executed, the child's own greet method continues.

Using the Parent Class Name Directly

You can also call the parent class's method directly by referencing the parent class name and passing self explicitly as the first argument.

Example:

class Parent: def greet(self): print("Hello from Parent") class Child(Parent): def greet(self): Parent.greet(self) # Explicitly calls the parent class's method print("Hello from Child") # Usage child = Child() child.greet()

Output:

Hello from Parent
Hello from Child

Explanation:

  • Parent.greet(self) directly invokes the greet method from the Parent class, bypassing super().

When to Use Each Approach

  1. Use super():

    • Recommended in most cases because it respects the method resolution order (MRO).
    • Essential in scenarios involving multiple inheritance, where super() ensures the correct parent class is called.
  2. Use Parent Class Name:

    • Useful for explicitly calling a specific parent class's method when you don't want to rely on MRO.
    • Can be necessary if the method isn't directly involved in multiple inheritance.

Example with Multiple Inheritance

Using super() ensures that all parent classes are called in the correct order.

class A: def greet(self): print("Hello from A") class B(A): def greet(self): print("Hello from B") super().greet() class C(B): def greet(self): print("Hello from C") super().greet() # Usage c = C() c.greet()

Output:

Hello from C
Hello from B
Hello from A

Explanation:

  • super() ensures that the methods are called in the correct MRO sequence (C -> B -> A).

Key Points

  • Use super() for clarity and compatibility with multiple inheritance.
  • Use the parent class name for explicit calls to a specific parent class.
  • Ensure that super() is correctly used in methods of all classes when working with multiple inheritance.

Happy coding!

TAGS
Coding Interview
CONTRIBUTOR
Arslan Ahmad
Arslan Ahmad
ex-FAANG engineering manager and author or Grokking series.
-

GET YOUR FREE

Coding Questions Catalog

Design Gurus Newsletter - Latest from our Blog
Boost your coding skills with our essential coding questions catalog.
Take a step towards a better tech career now!
Explore Answers
What not to say in a behavioral interview?
Which IT field is best without coding?
What is the rule of 40 in Atlassian?
What is Netflix's mission?
What is the difference between a startup and a tech company?
What is the job of Shopify?
Related Courses
New
Grokking the AI System Design Interview course cover
Grokking the AI System Design Interview
Learn to design AI systems the way interviewers expect: classic ML products, LLM and RAG architectures, and agentic systems, all through the lens of the system design interview.
4.8
(1,192 learners)
Discounted price for Your Region

$123

Grokking the Coding Interview: Patterns for Coding Questions course cover
Grokking the Coding Interview: Patterns for Coding Questions
The 24 essential patterns behind every coding interview question. Available in Java, Python, JavaScript, C++, C#, and Go. The most comprehensive coding interview course with 543 lessons. A smarter alternative to grinding LeetCode.
4.6
Discounted price for Your Region

$197

Grokking Modern AI Fundamentals course cover
Grokking Modern AI Fundamentals
Master the fundamentals of AI today to lead the tech revolution of tomorrow.
4.1
Discounted price for Your Region

$72

Design Gurus logo
One-Stop Portal For Tech Interviews.
Copyright © 2026 Design Gurus, LLC. All rights reserved.