[Tutor] multiple assignment on one line
Alan Gauld
alan.gauld at btinternet.com
Sun Nov 22 17:22:30 CET 2009
"Lie Ryan" <lie.1296 at gmail.com> wrote
I was a bit surprised this doesn't work though:
>
> a, b += k, k
>
What would you expect?
Remember that
a,b = c,d
is just tuple assignment without using parens (and parens are not part of
the tuple definition)
So using tuples
a,b += k,k
would unwrap as
a,b = (a,b) + (k,k) -> (a,b,k,k)
which should give an error since we are then unpacking 4 values
into two...
It doesn't really make sense.
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list