In python, everything works by reference:
>>> a = 1
>>> d = {'a':a}
>>> d['a']
1
>>> a = 2
>>> d['a']
1
I need something like this
>>> a = 1
>>> d = {'a':magical pointer to a}
>>> d['a']
1
>>> a = 2
>>> d['a']
2
What would you replace the magic pointer with so that python returns what I want.
I would appreciate general solutions (not only for the above dictionary with independent variables, but also for other collections and class / instance variables)
source
share