super() Parent proxy
Last updated: 2026-09-22
super() Parent proxy
super() returns a proxy to the parent class; lets you call parent implementations from a subclass.
| Category | Built-in Functions |
|---|---|
| Kind | Built-in Function |
| Python Version | all |
📝 Syntax
super([type[, object-or-type]])
⚙️ Parameters
| type Optional | The class; the zero-arg form infers it.(Default:None) |
|---|---|
| obj Optional | An instance or class for MRO resolution.(Default:None) |
Returns:A proxy to the next class in the MRO; methods can be called through it.
💥 Raises
RuntimeError— Raised when the zero-arg form is used outside a class.TypeError— Raised when obj is not an instance (or subclass) of type.
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
A.hello
B.hello
🏷️ Related Built-in Functions
💡 Related Cases
More case studies coming soon — check back later.
❓ FAQ
QWhat does super() do?
AIt calls the same-named parent implementation from a subclass method: super().hello() looks up and calls the hello method of the 'next class' in the MRO.
QWhy must super() be called inside a class method?
AThe zero-argument form automatically infers 'the current class and instance'; calling it outside a class (e.g. in a plain function) raises RuntimeError: super(): no arguments.
QWhen must I write super().__init__()?
AWhen the subclass overrides __init__ and still wants the parent class to perform its initialization; without it the parent's __init__ is not executed (unless the parent is object).
QIn what order does super() find parent classes under multiple inheritance?
AIt follows the MRO (Method Resolution Order). super() is not 'the direct parent' but 'the next class in the MRO', which correctly handles diamond inheritance and avoids calling a parent twice.