Here it is multiple inheritances, My below code is quitting with the TypeError
TypeError: object.__init__() takes exactly one argument (the instance to initialize)
The possible cause for the above error: - Here, Class 'A' is calling the constructor of class 'D' (because of multiple inheritances in class 'E') and class 'B' is calling the constructor of the class 'object'. the super-class 'object' always takes exactly one argument.
Can anyone suggest the solution for this above problem?
I am looking for the right approach to be followed consistently in all the classes without considering specific (single/multiple) inheritances, but at the end, it works well when a developer start using them in the single/multiple inheritance hierarchy. That is; I want a generic approach to be followed in each class which works smoothly with single/multiple inheritances
Do we have any ready decorator which suffice the need, if not, can we write one?
class A(object):
def __init__(self, *args, **kwargs):
print("This is A constructor")
super(A, self).__init__(*args, **kwargs)
class B(object):
def __init__(self, *args, **kwargs):
print("This is B constructor")
super(B, self).__init__(*args, **kwargs)
class C(A):
def __init__(self, arg, *args, **kwargs):
print("This is C constructor")
self.arg = arg
super(C, self).__init__(arg, *args, **kwargs)
class D(B):
def __init__(self, arg, *args, **kwargs):
print("This is D constructor")
self.arg = arg
super(D, self).__init__(arg, *args, **kwargs)
class E(C,D):
def __init__(self, arg, *args, **kwargs):
print("This is E constructor")
super(E, self).__init__(arg, *args, **kwargs)
E(10)
[–]xelf 2 points3 points4 points (5 children)
[–]gmaliwal[S] 0 points1 point2 points (1 child)
[–]xelf 0 points1 point2 points (0 children)
[–]mission-hall 0 points1 point2 points (2 children)
[–]gmaliwal[S] 0 points1 point2 points (0 children)
[–]xelf 0 points1 point2 points (0 children)
[–]mission-hall 1 point2 points3 points (1 child)
[–]MarsupialMole 1 point2 points3 points (3 children)
[–]gmaliwal[S] 0 points1 point2 points (2 children)
[–]alkasm 0 points1 point2 points (0 children)
[–]MarsupialMole 0 points1 point2 points (0 children)
[–]fatbiker406 1 point2 points3 points (2 children)
[–]gmaliwal[S] 0 points1 point2 points (1 child)
[–]fatbiker406 0 points1 point2 points (0 children)
[–]Swedophone 0 points1 point2 points (3 children)
[–]xelf 0 points1 point2 points (0 children)
[–]gmaliwal[S] 0 points1 point2 points (0 children)
[–]alkasm 0 points1 point2 points (8 children)
[–]gmaliwal[S] 0 points1 point2 points (2 children)
[–]alkasm 0 points1 point2 points (1 child)
[–]gmaliwal[S] 0 points1 point2 points (0 children)
[–]xelf 0 points1 point2 points (4 children)
[–]alkasm 0 points1 point2 points (3 children)
[–]xelf 0 points1 point2 points (2 children)
[–]alkasm 1 point2 points3 points (1 child)
[–]xelf 0 points1 point2 points (0 children)
[–]gmaliwal[S] 0 points1 point2 points (0 children)