I always believed that, in python, the syntax a=b
applied the value of b
to a
.
Although, in the example below, the value of image_init seems to be updated, what am I missing here??
import numpy as np
img = np.zeros((3,3))
img_init = img
img[-1,:]=[1]
print img
print
print img_init
Output:
[[ 0. 0. 0.]
[ 0. 0. 0.]
[ 1. 1. 1.]]
[[ 0. 0. 0.]
[ 0. 0. 0.]
[ 1. 1. 1.]]
EDIT: Let me correct a bit the question. First, both img and img_init are numpy array, not list. Then, I'm not looking for a way to copy the list, I'm just looking for the reason why img_init gets updated, Thanks already for all the answers!