The following code seems to append ['next']
twice to the self.list_of
, even though its acting on two independent objects.
class Higher:
def __init__(self, list_of: list = ['item1', 'item2'],):
self.list_of=list_of
self.list_of += ['next']
class NumberOne(Higher):
def __init__(self,**kwargs):
super().__init__(**kwargs)
class NumberTwo(Higher):
def __init__(self,**kwargs):
super().__init__(**kwargs)
if __name__=="__main__":
n = NumberOne()
m = NumberTwo()
print(m.list_of)
I would expect print(m.list_of)
to return ['item1', 'item2', 'next']
, instead of ['item1', 'item2', 'next', 'next']
I'm not sure whats causing this, can probably find a work around, but would rather understand whats going on.