On Dec 12, 1:44 pm, "Chris Rebert" <c...@rebertia.com> wrote:
> Python begs to differ, as those two statements are both semantically > identical in this case: That is because integers are immutable. When x += 1 is done on an int, there will be a rebinding. But try the same on say, a numpy array, and the result will be different: >>> import numpy >>> x = numpy.zeros(10) >>> id(x) 19504848 >>> x += 1 >>> id(x) 19504848 >>> x = x + 1 >>> id(x) 10451488 Whereas: >>> x = 1 >>> id(x) 10051256 >>> x += 1 >>> id(x) 10051244 >>> x = x + 1 >>> id(x) 10051232 -- http://mail.python.org/mailman/listinfo/python-list