Renae Lider
Renae Lider

Reputation: 1024

Should we "super()" in base class?

In Python 3 I use super from inherited classes as follows:

class Orange(Fruit):
    def __init__(self):
        super().__init__()

In the code snippet above Orange class inherits from Fruit class. Take a look at the parent class

class Fruit():
    def __init__(self):
        pass       # call super().__init__() here?

Do we need to call super from the parent/base class for the MRO to work effectively?

Upvotes: 0

Views: 71

Answers (1)

André Fratelli
André Fratelli

Reputation: 6068

No, in Python there's no point in calling __init__ on super for base classes and the MRO will still be properly initialised

Upvotes: 1

Related Questions