I'm having a small amount of difficulty understanding inheritance in Python. I was under the impression that when Class B
inherits from Class A
it inherits all of the values that were initialized in A. I've made up an example to demonstrate what I mean:
Class A():
def __init__(self,parameter):
self.initialize_parameter=4*parameter
Class B(A):
def __init__(self):
pass
def function(self,another_parameter):
return self.initialize_parameter*another_parameter
But in this case, calling:
B_instance=B()
print B_instance.function(10)
Returns an AttributeError
saying that class B doesn't not have self.initialized_parameter
So my question is, do I have to copy and paste all the initializations from A to B manually or is there a way that I can use them from within B without calling the A class itself? (I hope this is clear).