foo = [1, 2, 3]
foo[:][0] = 5
foo
doesn't change, also:
import copy
foo = [1, 2, 3]
boo = copy.copy(foo)
boo[0] = 5
Again, foo[0]
stays the same.
Why? The shallow copy creates new list, but shouldn't boo[0]
/boo[1]
/boo[2]
point to the same objects as foo[0]
/foo[1]
/foo[2]
?