packing unpacking depends on order.

Chris Angelico rosuav at gmail.com
Wed Sep 2 10:12:06 EDT 2015


On Wed, Sep 2, 2015 at 11:59 PM, Antoon Pardon
<antoon.pardon at rece.vub.ac.be> wrote:
>>  But if you're confused by
>> it, there's a simple solution: Don't reference the same "thing" more
>> than once on the LHS.
>
> That is rather extreme. It would mean we avoid the following:
>
> a[i], b[i] = b[i], a[i] # references i twice on the LHS.
> a[i], a[j] = a[j], a[i] # references a twice on the LHS.
>
> I think a better rule would be: Don't reference and bind
> the same "thing" on the LHS.

Sure. In any case, it's a programmer's choice; the language has
well-defined behaviour even if you don't follow a rule like this, so
it's just to help you keep things safe in your own head.

ChrisA



More information about the Python-list mailing list