class ChargingAccount(BankAccount):
def __init__(self, initialAmount):
BankAccount.__init__(self, initialAmount)
in the above sample bank account is the parent class,i think i understand why the init method is being called from bankaccount,to be able to use self,initial amount from bankaccount right?But if that is so why is it initialised in the child class before initialising it again on the second line.
Please use code tags when posting code. See
Posting Guidelines.
An instance of a class is created by calling a class object as a function. The static method
__new__() is called to create an instance which, in turn, calls the __init__() method of a class. The
__init__() method call initializes the contents of an
instance. Instance attributes and methods of class
BankAccount() would not be available to an instance of
ChargingAccount() unless its __init__() method was explicitly called. I hope this makes sense.