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/2000-July/006095.html below:

[Python-Dev] list comprehensions again...

[Python-Dev] list comprehensions again...Guido van Rossum guido@beopen.com
Tue, 11 Jul 2000 12:52:43 -0500
Oops.  I was simply mistaken on what the for-for syntax in list
comprehensions did!

Ideally, list comprehensions should support both parallel and nested
for loops, but I'm not sure how to decide to parse them if they both
occur.  E.g. what is this?

  [(x,y+z) for x in (1,2,3,4,5,6); for y in "abc" for z in "de"]

For me, the semicolon separates much stronger than the for, so (to me)
this feels like (applying parentheses to show grouping):

  (for x); (for y for z)

and would yield:

  [(1, "ad"), (2, "ae"), (3, "bd"), (4, "be"), (5, "cd"), (6, "ce")]

But is that the most useful?  And how do you write the other grouping?
I mean:

  (for x; for y) (for z)

which could yield:

  [(1, "ad"), (1, "ae"), (2, "bd"), (2, "be"), (3, "cd"), (3, "ce")]

A more practical question: if we're going to introduce [::], list
comprehensions, and parallel for loops, what would be the best way to
introduce the patches so that each patch changes as little as possible
of the code introduced by the previous patch?

--Guido van Rossum (home page: http://dinsdale.python.org/~guido/)



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