<br><br><div class="gmail_quote">On Thu, Feb 11, 2010 at 10:21, Matthew Russell <span dir="ltr"><<a href="mailto:matt.horizon5@gmail.com">matt.horizon5@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
this seems to work in python 2.x and python3.1, although I suspect it's a bug.<div><br></div><div>>>> t = (1, 2)</div><div>>>> t += (3,)</div><div>>>> t</div><div>(1, 2, 3)<br><br></div></blockquote>
<div>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:</div><div><br></div><div>>>> a = [1,2]</div><div>
>>> id(a)</div><div>11274840</div><div>>>> a += [3,]</div><div>>>> id(a)</div><div>11274840</div><div><br></div><div>a is a list; augmented assignment mutates it, but it's still the same object.</div>
<div><br></div><div>>>> b = (1,2)</div><div>>>> id(b)</div><div>13902872</div><div>>>> b += (3,)</div><div>>>> id(b)</div><div>13915800</div><div>>>></div><div> </div><div>b is a tuple; augmented assignment creates a new object and re-binds "b" to it.</div>
<div><br></div></div>-- <br>Tim Lesher <<a href="mailto:tlesher@gmail.com">tlesher@gmail.com</a>><br>