class InsurancePolicy:
def __init__(self, price_of_item):
self.price_of_insured_item = price_of_item
class VehicleInsurance(InsurancePolicy):
def get_rate(self):
return .001 * self.price_of_insured_item
class HomeInsurance(InsurancePolicy):
def get_rate(self):
return .00005 * self.price_of_insured_item
This code works, but why can I access self.price_of_insured_item
if I didn’t call the parent class’s __init__
method using super()
? Do child classes automatically inherit the __init__
method of the parent’s?