python deepcopy list code example
Example 1: python copy instance
import copy
class A(object):
def __init__(self, a)
self.a = a
a = A(38)
# Deepcopy
a2 = copy.deepcopy(a)
# Shallow copy -> use this if copy.deepcopy() fails
a3 = copy.copy(a)
Example 2: python copy variable
>>> import copy
>>> a = 0
>>> b = 2
>>> a = copy.copy(b)
>>> b += 1
>>> a
2
>>> b
3
Example 3: .copy python
new_list = list.copy()
# returns a new list without modifying the orginal list.