Search
 
SCRIPT & CODE EXAMPLE
 

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]]
>>>
Comment

PREVIOUS NEXT
Code Example
Python :: python http.server 
Python :: python opencv imresize 
Python :: create a generator from a list 
Python :: how to connect wifi using python 
Python :: if else python 
Python :: decimal in python 
Python :: np array to tuple 
Python :: python env 
Python :: tkinter template 
Python :: read from text file and append in list 
Python :: try except keyerror 
Python :: import excel python 
Python :: how to start an exe file in python 
Python :: python iter on a dic key value 
Python :: how to install neat 
Python :: csv writer python 
Python :: pil crop image 
Python :: python spotify player 
Python :: python dict key delete 
Python :: python get memory address 
Python :: custom keyboard telegram bot python 
Python :: how to connect an ml model to a web application 
Python :: pandas change date format to yyyy-mm-dd 
Python :: python iterate set 
Python :: get name of a file in python 
Python :: install python 3.6 dockerfile 
Python :: redirect in dajango 
Python :: remove first 3 columns pandas 
Python :: python how to replace a certain string in text 
Python :: python dict to dataclass 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =