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

NameTypeDescription
objobjectObject to inspect or copy.
memodictOptional 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)
Python Reference