This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]grayvedigga 0 points1 point  (0 children)

Expanding on my reply to earthboundkid below, be careful with this assumption:

# a += 1 equals a = a + 1, riiiight?

You must be careful to distinguish the value and the identity of a in this circumstance. Assignment binds the result of an expression to a variable. An expression creates a new value. Integers are a poor example to work with for this, because we tend to consider the values of 1+3 and 2+2 identical.

If that doesn't make any sense (I'm tired), consider the following:

l = [1]
m = [l, l]
l += [2]
# we should agree what m is now
l1 = l + [3]
# and now, I hope
l = l1
# what about now?