I have code like this:
class A(object):
def __init__(self):
self.a = 1
class B(A):
def __init__(self):
self.b = 2
super(self.__class__, self).__init__()
class C(B):
def __init__(self):
self.c = 3
super(self.__class__, self).__init__()
Instantiating B works as expected but instantiating C recursed infinitely and causes a stack overflow. How can I solve this?
Just think about this ... when you super init ... you call the base classes init, possibly overwriting all the work you have done. If you insist on use super with init, do it correctly. – Dec 08 '10 at 17:56