Copy a dictionary
A dictionary object has the method
copy. It performs a shallow copy of the dictionary.
Copy a set
Sets also have a
copymethod. You can use this method to perform a shallow copy.
Performing a deep copy
If you have nested lists, it is desireable to clone the nested lists as well. This action is called deep copy.
Performing a shallow copy
A shallow copy is a copy of a collection without performing a copy of its elements.
Performing a shallow copy of a list
You can create shallow copies of lists using slices.
This modified text is an extract of the original Stack Overflow Documentation created by following contributors
and released under CC BY-SA 3.0