Message311135
If multiple lists/dictionaries are in the same memory address (usually caused by var1 = var2), then altering one will effect every variable in that address.
The ways I've found to achieve this are:
>>> my_list[2] = "Spam"
>>> my_list += "9"
>>> my_list.insert(4, "Hello")
>>> dictvar.update({"Three": "Four"})
This was achieved using Python 3.6.4 32-bit and 3.6.3 64-bit (CPython), and happened in both IDLE and python.exe
List Example code:
x = ['a','b','c']
y = x #Now y and x share a memory address, because CPython does that
print(f"Sanity test - x and y share the same address = {x is y}")
y[1] = '123'
y += ["Foo"]
y.insert(-1, "Eleven")
#x's Expected Value: ['a','b','c']
print(x) #Actual Value |
|
Date |
User |
Action |
Args |
2018-01-29 13:57:45 | 64andy | set | recipients:
+ 64andy |
2018-01-29 13:57:45 | 64andy | set | messageid: <1517234265.82.0.467229070634.issue32712@psf.upfronthosting.co.za> |
2018-01-29 13:57:45 | 64andy | link | issue32712 messages |
2018-01-29 13:57:45 | 64andy | create | |
|