Gabriel Zachmann wrote:
> It seems to me that the following behavior of python (2.4.1) is inconsistent:
[snip]
> Why was it implemented like this??

Lists are mutable objects; integers are not. For a list, a += b is
equivalent to a.__iadd__(b), which is an in-place modification.

For an integer, no __iadd__ method is provided, so a += b is equivalent
to a = a.__add__(b), which is a rebinding operation rather than a
modification.

This question (or variants thereof) is asked on an almost daily basis;
please search before posting.

-- David

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to