On Dec 12, 1:56 pm, sturlamolden <sturlamol...@yahoo.no> wrote: > 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:
And a consequence of this is, if you have a function like def foobar(x): x += 1 then the parameter x will be modified given that x have mutable type. However, if we have a function like def foobar(x): x = x + 1 then x will not be modified, mutable or not. (Well, you could abuse operator overlaoding to make unexpected side effects in the latter case. But except for such insanity it will not have side-effects.) -- http://mail.python.org/mailman/listinfo/python-list