Actually about PEP 202 (listcomps), not (was RE: [Python-Dev] Lukewarm about range literals)

Fredrik Lundh
Tue, 29 Aug 2000 13:49:17 +0200

thomas wrote:
> > Saving two characters (":" vs "for") isn't worth it in Python.  The
> > vertical bar *would* be "worth it" to me, because that's what's used in
> > SETL, Haskell *and* common mathematical practice for "such that".  Alas,
> > as Guido is sure to point out, that's too hard to parse
> It's impossible to parse, of course, unless you require the parentheses
> around the expression preceding it :)
> [ (n) | n in range(100) if n%2 ]

I'm pretty sure Tim meant "|" instead of "if".  the SETL syntax is:

    [ n : n in range(100) | n%2 ]

(that is, ":" instead of for, and "|" or "st" instead of "if".  and yes,
they have nice range literals too, so don't take that "range" too
literal ;-)

in SETL, that can also be abbreviated to:

    [ n in range(100) | n%2 ]

which, of course, is a perfectly valid (though slightly obscure)
python expression...