copy Module

copy() #

Used to make a copy of mutable data like lists or dictionaries.

>>> spam = ['A', 'B', 'C', 'D']
>>> id(spam)
140619514272768
>>> cheese = copy.copy(spam)
>>> id(cheese)
140619515247488
>>> cheese[1] = 42
>>> spam
['A', 'B', 'C', 'D']
>>> cheese
['A', 42, 'C', 'D']

If the lists contains lists use copy.deepcopy() to copy those inner lists as well.