Hello,
I'm trying to update a dictionary using variable in a class. Something looking like this :
class testClass(object):
def __init__(self):
self.data0 = 0
self.data1 = 1
self.data2 = 2
self.data3 = 3
self.d = dict( data0 = self.data0, data1 = self.data1, data2 = self.data2, data3 = self.data3 )
def updateData(self,data):
self.data0 = data[0]
self.data1 = data[1]
self.data2 = data[2]
self.data3 = data[3]
for key in self.d:
print key + ' : ' + str(self.d[key])
if __name__ == '__main__':
test = testClass()
data = [4,5,6,7]
test.updateData(data)
Obviously the dictionary is not updated at all using this method.
Is there a way to make this work properly?
Thank you in advance !