Copy a dictionary

suggest change

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

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents