copy.copy(x) Return a shallow copy of x.
copy.deepcopy(x[, memo]) Return a deep copy of x.
The difference between shallow and deep copying is only relevant for compound objects (objects that contain other objects, like lists or class instances):
A=[1,2,3,4]
B=A
A.append(5)
A
B
B is indepdent with A
A=[1,2,3,4]
import copy
B=copy.deepcopy(A)
B
A.append(5)
A,B
B.append(6)
A,B
A[0]='a'
A,B
B[0]='A'
A,B
A=[1,2,3,4]
C=copy.copy(A)
A,C
A.append(5)
A,C
A[0]='a'
A,C
C[0]='A'
A,C
C.append(6)
A,C
A=[1,2,3,4]
B=copy.copy(A)
D=copy.deepcopy(A)
A,B,D
A.append(5)
A,B,D
A[0]='a'
A,B,D
so far, everyting is the same
A=[[1,2,3],['a','b','c']]
B=copy.copy(A)
D=copy.deepcopy(A)
E=A
A.append(['i','j','k'])
A,B,D,E
A[0][1]='II'
A,B,D,E
The difference is shown up!