[Tutor] multiple assignment on one line

Shashwat Anand anand.shashwat at gmail.com
Sun Nov 22 18:01:48 CET 2009


Ohh, I never thought it this way. Thanks for enlightening.

On Sun, Nov 22, 2009 at 9:52 PM, Alan Gauld <alan.gauld at btinternet.com>wrote:

>
> "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/
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091122/7844b700/attachment-0001.htm>


More information about the Tutor mailing list