我在这里更新 x,如果我在更新 x 后打印 y,y 将显示反射。但是,在第一个示例中, y 没有显示出这种变化。这就是我迷路的地方。谁可以给我解释一下这个?
x = 2
y = x + 3
### printing y will yield 5
x = 8 # ok am I updating the same storage space that x pointed to, or is abandoning it and creating
# another with a value of 8?
### printing y will still yield 5 (why is that? if Y always points to x and adds 3 to it?)
in contrast with this:
x = [1,2,3]
y = [x,4,5,6]
x[0] = 50
y[2] = 80
z = y[:] + [100,101,1020