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/006133.html below:

[Python-Dev] re: list comprehension / pop quiz

[Python-Dev] re: list comprehension / pop quizKa-Ping Yee Ka-Ping Yee <pingster@ilm.com>
Tue, 11 Jul 2000 15:02:17 -0700 (PDT)
On Tue, 11 Jul 2000, Jeremy Hylton wrote:
> If we end up calling this new feature list comprehensions, we might
> create the expectation that they behave like list comprehensions in
> other languages.

Good point.

> >[ f x | x <- xs ]
[...]
> >[ (x,y) | x <- xs, y <- ys ]

The closest translations for these i can imagine are

    [ f(x), for x in xs ]

    [ (x,y), for x in xs, for y in ys ]

I'd say the above has to be about my favourite for ease of reading.

I think the following grammar would work:

    listmaker: test [',' (list_iter | [test (',' test)* [',']])]
    list_iter: list_for | list_if
    list_for: 'for' exprlist 'in' testlist [',' list_iter]
    list_if: 'if' test [',' list_iter]


-- ?!ng





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