Jotting one man's journey through software development, programming, and technology
◀️ Home
classsuper()super() is used inside a class—typically in the __init__ method—to call a method from a parent (or superclass). It’s most commonly used to extend the functionality of an inherited method without completely overriding it.
In the context of __init__, super() is used to:
__init__ method of the parent class.Example:
class Animal:
def __init__(self):
print("Animal initialized")
class Dog(Animal):
def __init__(self):
super().__init__() # Calls Animal's __init__
print("Dog initialized")
Output:
# Animal initialized
# Dog initialized