I would like to know what the difference is between the last two list assignments below
List1 = [0x1,0x2,0x3,0x4]
print('{}, 0x{:X}'.format(List1, id(List1)))
List1 = List1[1:]
print('{}, 0x{:X}'.format(List1, id(List1)))
List1[:] = List1[1:]
print('{}, 0x{:X}'.format(List1, id(List1)))
The print out when I execute this is
[1, 2, 3, 4], 0x2DBA09E8C88
[2, 3, 4], 0x2DBA1342B48
[3, 4], 0x2DBA1342B48
After I have created the list.
I make what I believe is a shallow copy.
But what does the last assignment do ? It keeps its address so there is not created a new object.
I cant seem to find en explanation on this on this in the net, what should I look for
Regards