super()
Built-in FunctionPython 2.0+Intermediate
Returns a proxy object that delegates calls to a parent class
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
Learn by Difficulty
Quick Example
python
class Animal: def speak(self): return "..." class Dog(Animal): def speak(self): parent = super().speak() return f"{parent} Woof!" print(Dog().speak())
super() is a built-in function that returns a proxy object that delegates calls to a parent class.
Try in PlaygroundTags
builtinfunctioncoreoopinheritance
Related Items
class
Keyword
Defines a new class (blueprint for creating objects)
__init__
Dunder Method
Constructor; called when a new instance is created to initialize its attributes
__mro__
Dunder Attribute
Method Resolution Order; the order in which base classes are searched
isinstance()
Built-in Function
Returns True if an object is an instance of a given class or tuple of classes
issubclass()
Built-in Function
Returns True if a class is a subclass of another class