Here is something I've been having a doubt about. Consider the following snippet.
class A(object):
def check(self):
super(A, self).check()
print "inside a"
class B(object):
def check(self):
print "inside b"
class C(A, B):
pass
c = C()
c.setup()
Now this gives the output,
inside b
inside a
Passing this through pdb i see that on reaching A.setup(), B.setup() is being called. However, the call from A is to the check method of its superclass; as it does not exist the call moves from that point to B.check().
- Could someone explain or point me to a document which explains how this works internally? I could'nt find any.
- Could someone show me a similar implementation in C++/Java? I think comparing it with other languages would help me understand the problem at hand better.
Many thanks.