I would like to achieve the same behaviour you get when copying mutable variables in python with an immutable integer. Such as follows:
>>>b = [3,4]
>>>a = b
>>>a
[3,4]
>>>b.append(2)
>>>b
[3,4,2]
>>>a
[3,4,2]
But instead of lists, I have something as follows:
>>>b = 3
>>>a = b
>>>a
3
>>>b += 1
>>>b
4
>>>a
3
Which is not what I want, I would ideally like a
to update to the new value of b
, which is 4
. So essentially a pointer.
How would I achieve this in python?