class A:
def __init__(self, value):
self.value = value
class B:
def __init__(self, name):
self.name = name
class C(A, B):
def __init__(self, name, value):
super(A, self).__init__(value)
super(B, self).__init__(name)
t = C('Name', 0)
Результаты:
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2021.1.2\plugins\python-ce\helpers\pydev\pydevd.py", line 1483, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2021.1.2\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/python/others/tests.py", line 17, in <module>
t = C('Name', 0)
File "C:/python/others/tests.py", line 14, in __init__
super(B, self).__init__(name)
TypeError: object.__init__() takes exactly one argument (the instance to initialize)
python-BaseException
Process finished with exit code 1