The super() function returns a proxy object that delegates method calls to a parent or sibling class.
super().method() → calls parent's methodMethod Override with super() - Extends parent method functionality
super().method() - Calls parent method and enhances result
Animal → Dog
speak()
When super() is called in Dog, it looks for the next class in MRO
Base Class
def speak(self):
return "Animal speak method called"Derived Class
def speak(self):
return super().speak() + " - Enhanced by Dog"my_dog.speak() called
Dog.speak() executes
super().speak() calls Animal.speak()
Animal.speak() returns "Animal speak method called"
Final result: "Animal speak method called - Enhanced by Dog"