-2
我有兩個類。在面向對象的方法論中,我可以從低級別類改變父屬性。在Python中,我怎樣才能改變其他類的父母的變量?我有什麼如何更改父類的屬性
class Concurrent(threading.Thread):
def __init__(self):
self.rec = Rec()
self.rec.start()
self.parentvar = None # I have change this variable
self.secondParentVar = [] # or use this
class Rec(Concurrent):
def run(self):
# from here, change variable of the parent Conccurent class variable
什麼父變量是你想改變什麼? –
所以你想改變'self.rec = Rec()'或者什麼? – Serial
@SnakesandCoffee我沒有放任何變量名。如果你想'parentVar = None' – user2396467