說我有一類動態繼承
class ParentA:
def initialize(self):
pass
def some_event(self):
pass
def order(self, value):
# handle order in some way for Parent A
class ParentB:
def initialize(self):
pass
def some_event(self):
pass
def order(self, value):
# handle order in another for Parent B
的2層不同的實現如何動態讓無論從ParentA
或ParentB
一些第三類繼承基於這樣的事?
class MyCode:
def initialize(self):
self.initial_value = 1
def some_event(self):
# handle event
order(self.initial_value)
# let MyCode inherit from ParentA and run
run(my_code, ParentA)
我重新打開的問題becaused的DUP約爲創建後改變類的實例,而這個問題是關於用不同的基類創建*類*的。 – shx2