2 Respostas
+ 4
If you define several __init__ methods, each new method will just override the preceding definition(s), so there'll always be only one __init__ method.
There's no need for constructor overloading since you can just use variable arguments and make your __init__ method flexible enough to react to all kinds of object initializations:
def __init__(self, *args):
print(len(args), 'were passed')
if args:
print('first argument is of type', type(args[0]))
etc.
0
def __init__(self, *args, **kwargs):
...