我希望能够从两个不同的输入到其__init__
方法中的不同类继承。我如何正确地从它们继承?如何从具有不同__init__输入的多个类继承?
下面是什么,我试图完成一个简单的例子:
class a:
def __init__(self):
print("Hello")
class b(a):
def __init__(self):
super().__init__()
print("World")
class c:
def __init__(self, text):
print(text)
class d(a, c):
def __init__(self):
super().__init__('Kronos') # <-- This breaks (and understandably so)
虽然类似多重继承的其他许多问题(即How does Python's super() work with multiple inheritance?),我正在寻找如何继承从具有不同输入的多个类到它们的__init__
。
的可能的复制[如何Python的超()与多重继承工作?](http://stackoverflow.com/questions/3277367/how-does -pythons-super-work-with-multiple-inheritance) – electrometro
考虑在你的'__init__'方法中加入一个'* args,** kwargs' –
你可以试试我的编辑 – DreadfulWeather