<div dir="ltr">That's interesting. I agree with you, I'd prefer the second result in both cases.<div><br></div><div>But makes sense as it evaluates left to right and seems to break up the unpacking into separate statements.</div><div><br></div><div>Could be useful if you want to hold the results of a generator in sequence, can call the same function multiple times and unpack as above.</div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Sep 2, 2015 at 11:07 AM Antoon Pardon <<a href="mailto:antoon.pardon@rece.vub.ac.be">antoon.pardon@rece.vub.ac.be</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
>>> a = [1, 2, 3, 4, 5]<br>
>>> b = 1<br>
>>> b, a[b] = a[b], b<br>
>>> a<br>
[1, 2, 1, 4, 5]<br>
>>> a = [1, 2, 3, 4, 5]<br>
>>> b = 1<br>
>>> a[b], b = b, a[b]<br>
>>> a<br>
[1, 1, 3, 4, 5]<br>
<br>
I think I understand how it gets these results<br>
but I'm not really happy with them. I think python<br>
should give the second result in both cases.<br>
<br>
--<br>
Antoon Pardon<br>
<br>
--<br>
<a href="https://mail.python.org/mailman/listinfo/python-list" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-list</a><br>
</blockquote></div><div dir="ltr">-- <br></div><div dir="ltr"> - Nick</div>