[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Tuples and immutability

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

   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."