First thing that comes to mind : why do I need to name the superclass
explicitly, instead of passing in self.__class__
(or better still,
type(self)
) ?
Because:
class Base(object):
def method(self):
print 'original'
class Derived(Base):
def method(self):
print 'derived'
super(type(self), self).method()
class Subclass(Derived):
def method(self):
print 'subclass of derived'
super(Subclass, self).method()
leads to:
>>> Subclass().method()
subclass of derived
derived
derived
derived
<...>
File "<stdin>", line 4, in method
File "<stdin>", line 4, in method
File "<stdin>", line 4, in method
RuntimeError: maximum recursion depth exceeded while calling a Python object
And this pretty much explains the second question I had.