11 Feb
2010
11 Feb
'10
3:38 p.m.
On Thu, Feb 11, 2010 at 10:21, Matthew Russell
this seems to work in python 2.x and python3.1, although I suspect it's a bug.
t = (1, 2) t += (3,) t (1, 2, 3)
The object "t" references at the end isn't the same one that it references at the beginning. Note the difference between lists and tuples here:
a = [1,2] id(a) 11274840 a += [3,] id(a) 11274840
a is a list; augmented assignment mutates it, but it's still the same object.
b = (1,2) id(b) 13902872 b += (3,) id(b) 13915800
b is a tuple; augmented assignment creates a new object and re-binds "b" to
it.
--
Tim Lesher