Python super() built-in function
From the Python 3 documentation
Return a proxy object that delegates method calls to a parent or sibling class of type. This is useful for accessing inherited methods that have been overridden in a class.
Introduction
The super()
function is used to call a method from a parent class. This is particularly useful in inheritance when you want to extend the functionality of a parent’s method without completely overriding it.
Example
class Parent:
def greet(self):
print("Hello from Parent")
class Child(Parent):
def greet(self):
# Call the parent's greet method
super().greet()
print("Hello from Child")
c = Child()
c.greet()
# Output:
# Hello from Parent
# Hello from Child