Straight to the point. The next statements have the effect of swapping the contents of the two list elements of the python 2D-list:
a = [[1,2,3],
[4,5,6]]
b = [[7,8,9],
[10,11,12]]
tmp = a[1]
a[1] = b[1]
b[1] = tmp
output:
a = [[1,2,3],
[10,11,12]]
b = [[7,8,9],
[4,5,6]]
For the numpy array type this would not have happened.
a = np.array([[1,2,3],
[4,5,6]])
b = np.array([[7,8,9],
[10,11,12]])
tmp = a[1]
a[1] = b[1]
b[1] = tmp
output:
a = array([[ 1, 2, 3],
[10, 11, 12]])
b = array([[ 7, 8, 9],
[10, 11, 12]])
Why is that so?