I occasionally see the list slice syntax used in Python code like this:
newList = oldList[:]
Surely this is just the same as:
As it has already been answered, I'll simply add a simple demonstration:
>>> a = [1, 2, 3, 4] >>> b = a >>> c = a[:] >>> b[2] = 10 >>> c[3] = 20 >>> a [1, 2, 10, 4] >>> b [1, 2, 10, 4] >>> c [1, 2, 3, 20]