Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python copy deep arrays without reference

# deep copying of arrays
>>> from copy import deepcopy
>>> a = [[1,2],[3],[4]]

>>> b = a[:]
>>> c = deepcopy(a)

>>> c[0].append(9)

>>> a
[[1, 2], [3], [4]]
>>> b
[[1, 2], [3], [4]]
>>> c
[[1, 2, 9], [3], [4]]
>>>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #copy #deep #arrays #reference
ADD COMMENT
Topic
Name
5+5 =