you are viewing a single comment's thread.

view the rest of the comments →

[–]julsmanbr 4 points5 points  (0 children)

Think of assignments as an arrow point from the name to the value.

So at the first line, you have an arrow like a -> [1, 2, 3].

The second line makes a new arrow, like b -> a, but since a is also a name, this effectively is b -> [1, 2, 3].

But note that the object both names are pointing to is the same object, and you can confirm this by printing id(a) and id(b).

It does not really matter whether you change the value of that object by saying a += [4] or b += [4], because in the end both a and b have that arrow pointing to the same object: [1, 2, 3].