Python Language Performing a shallow copy of a list


Example

You can create shallow copies of lists using slices.

>>> l1 = [1,2,3]
>>> l2 = l1[:]     # Perform the shallow copy.
>>> l2
[1,2,3]
>>> l1 is l2
False