A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-August/046685.html below:

[Python-Dev] Tuple/list assignment question

[Python-Dev] Tuple/list assignment questionNick Coghlan ncoghlan at iinet.net.au
Tue Aug 3 09:02:53 CEST 2004
Dave Cole wrote:

> Is there any reason why something like this would not be a good idea?
> 
>  >>> a_list = [1, 2, 3, 4, 5]
>  >>> a, b, *c = a_list
> 
> You could then do things like this:
> 
>  >>> lol = [[1, 2], [3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13]]
>  >>> for a, b *c in lol:
> ...
> 
> - Dave
> 

As opposed to:

 >>> for a, b, c in ((x[0], x[1], x[2:]) for x in lol): print a, b, c


With generator expressions around, I don't know that this case is common 
enough for special casing. . .

Cheers,
Nick.

-- 
Nick Coghlan               |     Brisbane, Australia
Email: ncoghlan at email.com  | Mobile: +61 409 573 268
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4