0Pricing
Python Academy · Lesson

Method Overriding and super()

Override parent methods and call them with super().

Introduction

Method overriding lets child classes customize inherited behavior. super() lets you call the original implementation.

Overriding Basics

Define the same method name in the child class to replace the parent's version for all instances of the child.
class Greeter:
    def greet(self): return 'Hello'
class FormalGreeter(Greeter):
    def greet(self): return 'Good day'
print(FormalGreeter().greet())

All lessons in this course

  1. Single Inheritance
  2. Method Overriding and super()
  3. Multiple Inheritance and MRO
  4. Polymorphism and Duck Typing
← Back to Python Academy