Here is my problem:
>>> row0 = [0, 0, 0]
>>> row1 = [0, 0, 0]
>>> field = {'hor' : (row0[0], row1[0])}
>>> field
{'hor': (0, 0)}
>>> row0[0] = 1
>>> field
{'hor': (0, 0)}
What I actually want to have would be:
>>> field
{'hor': (1, 0)}
I understand this behaviour, but how can I hack around it?
The only way I could think of was this:
I could store the ID of the items in the dictionary, like this:
row0 = [0, 0]
row1 = [0, 0]
field = {'hor' : (id(row0[0]), id(row1[0]))}
But the problem here is the access to the variables by the id (I just need read access). I googled a bit, and the only possible solution I found was using globals().items(), like that:
for key, value in globals().items(): print key, value, id(value)
I hope someone has a better solution for my problem. Thanks in advance!
EDIT:
Sorry, the first code example was a bit too simple. My case more looks like the example above.
As Felix Kling pointed out: You cannot have a reference to primitive values