super()

A built-in that lets a method call the version of itself in the parent class, most often super().__init__(...) in an initialiser.

In more detail

It follows the method resolution order, so it works correctly even with several parent classes. Without it, a subclass initialiser that does its own setup would skip the parent's setup entirely.

Example

class Puppy(Dog):
    def __init__(self, name):
        super().__init__(name)
        self.age = 0

Related terms

Taught in

References

Certification courses