Interpreting Left to right?
Terry Reedy
tjreedy at udel.edu
Fri Jun 24 20:56:58 EDT 2011
On 6/24/2011 5:08 PM, Tycho Andersen wrote:
> "An assignment statement evaluates the expression list (remember that
> this can be a single expression or a comma-separated list, the latter
> yielding a tuple) and assigns the single resulting object to each of
> the target lists, from left to right."
This is the 'other' type of 'multiple assignment'
a,b,c = 1,2,3
Order matters here too.
a,a[1] = [1,2],3
a
# [1,3]
# but
a[1], a = 3, [1,2]
will either fail or modify what a was previously bound to before
rebinding a to [1,2].
--
Terry Jan Reedy
More information about the Python-list
mailing list