re: Dead Simple Python: Classes VIEW POST


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


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.)


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.

code of conduct - report abuse