Übergeordnete Python-Aufrufmethode Mehrfachvererbung
Also, ich habe eine Situation wie diese.
class A(object):
def foo(self, call_from):
print "foo from A, call from %s" % call_from
class B(object):
def foo(self, call_from):
print "foo from B, call from %s" % call_from
class C(object):
def foo(self, call_from):
print "foo from C, call from %s" % call_from
class D(A, B, C):
def foo(self):
print "foo from D"
super(D, self).foo("D")
d = D()
d.foo()
Das Ergebnis des Codes ist
foo from D
foo from A, call from D
Ich möchte alle übergeordneten Methoden aufrufen, in diesem Fall foo method, fromD
klasse ohne super bei der übergeordneten klasse wieA
. Ich will nur das super von der anrufenD
Klasse. DasA
, B
, undC
class ist genau wie mixin class und ich möchte all foo method von aufrufenD
. Wie kann ich das erreichen?