[Python-Dev] Features for Python 2.0

Moshe Zadka Moshe Zadka <moshez@math.huji.ac.il>
Tue, 25 Jul 2000 16:30:16 +0300 (IDT)

On Tue, 25 Jul 2000, Guido van Rossum wrote:

> > List comprehensions' problems is that we cannot find a syntax that we all
> > agree is readable. Perhaps the answer is not list comprehensions, but
> > lexical scoping combined with steroid versions of map and filter, together
> > with zip to bind things together. 
> I'm about 3000 messages behind in that particular discussion.  I still
> really like Greg Ewing's original syntax:
>   [x for x in seq]

I think the main problem with this syntax was that there is no seperator
between the expression and the "for". Not a parser issue, but a human one:
the same reason there is a colon after the "if" keyword.


[x; for x in seq]


[x: for x in seq]

each had their objections. These will all probably be in the PEP, so
I'll shut up now.

>   [x+y for x in seq1 for y in seq2]
>   [x for x in seq if pred(x)]
>   [x, x*2 for x in seq]

And what about

[x+y for x in seq1 for y in seq2 if y>2 if x<3]


[x+y for x in seq1 if x<3 for y in seq2 if y>2]

What is allowed? Aren't we being a bit too TIMTOWTDIish here?
(From there on, the discussion diverged)

Moshe Zadka <moshez@math.huji.ac.il>
There is no IGLU cabal.