Tuples and immutability
Marko Rauhamaa
marko at pacujo.net
Fri Feb 28 02:54:48 EST 2014
John O'Hagan <research at johnohagan.com>:
> Same object, just a different name - but a different result. I get
> why, but still find that odd.
The general principle is stated in the language specification:
<URL: http://docs.python.org/3.2/reference/simple_stmts.html
#augmented-assignment-statements>:
Also, when possible, the actual operation is performed in-place,
meaning that rather than creating a new object and assigning that to
the target, the old object is modified instead.
[...] with the exception of the possible in-place behavior, the
binary operation performed by augmented assignment [x += y] is the
same as the normal binary operations [x = x + y].
We should call += "dual-use technology."
Marko
More information about the Python-list
mailing list