About __init__ function

Does all class need to have init function? What does it do?

No, not all classes needed.

Basically what it does is set some ‘initial’ data or configuration when needed.

Let’s say that a class has a ‘color’ attribute that will be ‘orange’ by default, you can set ‘color=orange’ unless some other color is specified on object creation. If not specified it’ll always be orange set by the init method when object is created.

1 Like

Class B inherits from Class A - is A.init inherited as well?