Copy Functions
copy.deepcopy()
Recursively copy supported compound objects, using a memo to preserve shared references and terminate cycles. Custom __deepcopy__ hooks can choose what remains shared. Not all objects can be copied.
Formal Syntax & Structure
python syntaxpython
copy.deepcopy(obj, memo=None)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| obj | object | Object to inspect or copy. |
| memo | dict | Optional mapping used to track objects already copied. |
Return Value
object
The object result described above.
Working Example
Example Snippetpython
import copyoriginal=[[1]]clone=copy.deepcopy(original)clone[0].append(9)print(original, clone)