Michael Selik wrote:
The += operator was meant as an alias for ``x = x + 1``. The fact that it mutates a list is somewhat of a surprise.

That's very much a matter of opinion. For every person who
thinks this is a surprise, you can find another that thinks
it's obvious that += should mutate a list, and is surprised
by the fact that it works on immutable types at all.

Some other languages make no distinction between mutation and reassignment. Perhaps you're thinking of one of those other languages.

Most languages, actually. I'm not aware of any other
language with a += operator that has this dual interpretation
of its meaning -- which is probably why almost everyone gets
surprised by at least one of its meanings. :-)

Maybe we should call it the "Spanish Inquisition operator".

--
Greg
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to