I'm a bit doubtful about the inheritance issue in python
.
In the following test, I expected that quack
would print the same value for the two classes I created:
class A(object):
a,b = (None, None)
def __init__(self):
self.a = 'a'
def quack(self):
return 'retorno "%s" ' % self.a
class B(A):
def __init__(self):
super(A, self).__init__()
self.b = 'b'
My test was done like this:
b = B()
a = A()
print(b.quack())
print(a.quack())
The output was:
retorno "None"
retorno "a"
But I thought the two of them should return the same thing.
The inheritance of the a
property only worked as I expected when I changed the super
snippet to this:
A.__init(self)
Return:
retorno "a"
retorno "a"
Having these two cases, what is the difference between the two statements I created?
Why did not super use the parent class method?