[PEP202 listcomps] (was RE: [Python-Dev] Product iteration)

Fredrik Lundh Fredrik Lundh" <effbot@telia.com
Wed, 26 Jul 2000 10:55:46 +0200

guido wrote:
> > It derives in turn from SETL, which followed common set-theoretic
> > notation.  This "grabbed" Guido; LISP spellings never did, and I bet
> > never will.
> I've never used or even seen SETL, but there is a connection: SETL had
> a profound influence on the designers of ABC, in particular Lambert
> Meertens, who spent a sabbatical year working with the folks at New
> York University who wrote the first validated Ada compiler in SETL.

found this one:

interesting reading.  SETL sure has a pythonic feel...

with a few improvements, of course (like the [start next end]
range literals...  too late to fix that in python, I suppose...)

and personally, I prefer their "tuple former" syntax over the the
current PEP202 proposal:

    [expression : iterator]

    [n : n in [1:100]]
    [(x**2, x) : x in [1:5]]
    [a : a in y if a > 5]

(all examples are slightly pythonified; most notably, they
use "|" or "st" (such that) instead of "if")

the expression can be omitted if it's the same thing as the
loop variable, *and* there's at least one "if" clause:

    [a in y if a > 5]

also note that their "for-in" statement can take qualifiers:

    for a in y if a > 5:

is there any special reason why we cannot use colon instead
of "for"?