I tried to find out with googling, but it seems not explained.
There are four classes, for example, which are A, B, C, and D.
C is sub-class of D. A and B is calling C.
Class A:
def __init__(self):
self.c = C()
Class B:
def __init__(self):
self.c = C()
Class C(D):
def __init__(self):
print('it is C')
Class D:
def __init__(self):
print('it is D')
a = A()
b = b()
In this case, it will initiate twice for Class C. So, 'it is C' and 'it is D' strings represent twice. And.. I think it's ... not normal.
Unlike Java, it seems that Python doesn't support constructor overloading.
In this case, can I call C only though? Or, could I get an advice for using init in Python?
Thank you.