packing unpacking depends on order.

Mark Lawrence breamoreboy at yahoo.co.uk
Wed Sep 2 18:40:55 CEST 2015


On 02/09/2015 11:01, Antoon Pardon wrote:
>
>>>> a = [1, 2, 3, 4, 5]
>>>> b = 1
>>>> b, a[b] = a[b], b
>>>> a
> [1, 2, 1, 4, 5]
>>>> a = [1, 2, 3, 4, 5]
>>>> b = 1
>>>> a[b], b = b, a[b]
>>>> a
> [1, 1, 3, 4, 5]
>
> I think I understand how it gets these results
> but I'm not really happy with them. I think python
> should give the second result in both cases.
>

You might find this interesting 
https://www.cyphar.com/blog/post/tuple-unpacking-oddness

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence



More information about the Python-list mailing list