Being new to Python, I'm reading book on Object Oriented Python and came across the following code while the writer experiments with defining the PARENT class which will be inherited by subclasses.
class Property:
def __init__(self, square_feet='', beds='', baths='', **kwargs):
super().__init__(**kwargs)
self.square_feet = square_feet
self.num_bedrooms = beds
self.num_baths = baths
I understand the call to super().__init__(**kwargs)
is used when we are inheriting to a subclass. But I don't get why do we need to make this call when we are defining the parent class. Does it have to do that by default every class in Python is subclass of "Object" class?
The writer explains that:
We've also included a call to super().__init__
in case we are not the last call in the multiple inheritance chain. In this case, we're "consuming" the keyword arguments because we know they won't be needed at other levels of the inheritance hierarchy.
I totally don't get that why do we have to do this call at PARENT CLASS level when we are not inheriting?