(In python)
I want to be able to write something like a + b
, and so that as a result a
has the value of the sum of a
and b
, also so that id(a)
does not change (that is, change data at the address of a variable in memory rather than create a new address with the result of the sum and refer to it with a
).
My attempt to use +=
fails:
a, b = 5, 6
start_id = id(a)
a += b
print(start_id == id(a))
# Outputs: False