I am learning python via dive into python. Got few questions and unable to understand, even through the documentation.
1) BaseClass
2) InheritClass
What exactly happens when we assign a InheritClass instance to a variable, when the InheritClass doesn’t contain an __init__ method and BaseClass does ?
- Is the BaseClass
__init__method called automatically - Also, tell me other things that happen under the hood.
Actually the fileInfo.py example is giving me serious headache, i am just unable to understand as to how the things are working. Following
Yes,
BaseClass.__init__will be called automatically. Same goes for any other methods defined in the parent class but not the child class. Observe:The child inherits its parent’s methods. It can override them, but it doesn’t have to.