Calling a method through super() inside a subclass looks up and calls that method on the parent class, or, more precisely, the next class in the method resolution order for multiple inheritance, automatically passing the current instance along. It's most commonly used inside a subclass's __init__ to run the parent's setup logic before adding the subclass's own attributes, which avoids duplicating the parent's initialization code. Without arguments, super() automatically figures out the current class and instance from context — the explicit two-argument form is the older, more verbose Python 2-compatible syntax.
1Understanding super() Function
Calling a method through super() inside a subclass looks up and calls that method on the parent class, or, more precisely, the next class in the method resolution order for multiple inheritance, automatically passing the current instance along. It's most commonly used inside a subclass's __init__ to run the parent's setup logic before adding the subclass's own attributes, which avoids duplicating the parent's initialization code. Without arguments, super() automatically figures out the current class and instance from context — the explicit two-argument form is the older, more verbose Python 2-compatible syntax.
Forgetting to call the parent's __init__ through super() in a subclass's constructor is a common bug: the subclass gets its own new attributes but silently skips whatever setup the parent class expected to happen, leaving the object partially initialized.
class Vehicle:
def __init__(self, wheels):
self.wheels = wheels
class Car(Vehicle):
def __init__(self, brand):
super().__init__(wheels=4)
self.brand = brand
c = Car("Toyota")
print(c.wheels, c.brand)2Practical Example
Here is a real-world application of super() Function showing how it is used in production Python code.
class Logger:
def log(self, message):
print(f"[LOG] {message}")
class TimestampedLogger(Logger):
def log(self, message):
super().log(f"2026-01-01 {message}")
TimestampedLogger().log("Server started")3Best Practices
Follow these guidelines when working with super() Function:
1. Call super().__init__(...) as the first line of a subclass's constructor, before setting up the subclass's own attributes
2. Use the zero-argument super() form in Python 3 instead of the older two-argument syntax
3. Use super() to extend a parent method's behavior (call it, then add more) rather than duplicating the parent's logic inside the override
Tip: Forgetting to call the parent's __init__ through super() in a subclass's constructor is a common bug: the subclass gets its own new attributes but silently skips whatever setup the parent class expected to happen, leaving the object partially initialized.
class Vehicle:
def __init__(self, wheels):
self.wheels = wheels
class Car(Vehicle):
def __init__(self, brand):
super().__init__(wheels=4)
self.brand = brand
c = Car("Toyota")
print(c.wheels, c.brand)