Python 2 documentation says that super() function \"returns a proxy object that delegates method calls to a parent or sibling class of type.\"
The questions:
A sibling is a class with the same parent, as you suspected. The case you're missing is that super
could call a sibling method if this class itself is being multiply inherited from:
class A(object):
def something(self):
print("A")
class B(A):
def something(self):
print("B")
class C(A):
def something(self):
print("C, about to call super()")
super(C, self).something()
class D(C, B):
def something(self):
super(D, self).something()
>>> D().something()
C, about to call super()
B
In C
, we called super()
, but we got B
- which is a sibling, not a parent and not the parent of a sibling, but an actual direct sibling of C
.