How to copy an object in Python

You can copy an object in Python using deepcopy :
from copy import deepcopy B = deepcopy(A)
The "=" does is to assign another reference to the same object in memory . The deepcopy creates a whole new object in memory with the values of A and B will reference it. You can test it using the following:
B = A print( id(A), id(B))

Above program output same Ids

B = deepcopy(A) print( id(A), id(B)

Above program output different Ids