I've run into a problem with inheritance in python that I know how to avoid, but don't completely understand. The problem occured while making a menu but I've stripped down the code to only the real problem. code:
class menu:
buttonlist=[]
>>> class av(menu):
def __init__(self, num):
self.buttonlist.append(num)
print self.buttonlist
>>> AV=av(12)
[12]
>>> class main(menu):
def __init__(self, num):
self.buttonlist.append(num)
print self.buttonlist
>>> Main=main(14)
[12, 14]
>>> AV.buttonlist
[12, 14]
I'd expect to get [14] in return by the 'Main=main(14)', and [12] with the 'AV.buttonlist' but instead it seems append has appended the list in all classes and objects :S can anyone explain to me why this is?
thanks in advance!