DEV Community

Discussion on: Dead Simple Python: Classes

Collapse
 
ravin309 profile image
Ravinder Kumar

In inheritance, what if we do not write 'super().init()' in child class' init() method? Does child class not call it by default?

Collapse
 
codemouse92 profile image
Jason C. McDonald

No, it doesn't, as far as I know. As mentioned in the Zen of Python, Explicit is better than implicit. It's part of the language philosophy.

We often need to handle passing data to the parent __init__() in a specific way, and we may need to do some other things first, so Python just assumes we know best how to handle that.

Imagine how maddening it could get if Python sometimes called it for you, but sometimes not! (Some languages actually are confusing like that, but Python aims to be obvious.)

Collapse
 
ravin309 profile image
Ravinder Kumar

Thanks for clarifying!
It would be very helpful if you also explain MRO (Method Resolution Order) in context of Python 3 in any upcoming series.