Python Language Copy a dictionary


Example

A dictionary object has the method copy. It performs a shallow copy of the dictionary.

>>> d1 = {1:[]}
>>> d2 = d1.copy()
>>> d1 is d2
False
>>> d1[1] is d2[1]
True