[Python-Dev] Features for Python 2.0

Fredrik Lundh Fredrik Lundh" <effbot@telia.com
Tue, 25 Jul 2000 17:01:35 +0200

I wrote:

> guido wrote:
> > This is a (minor) open issue; I'd be happy with requiring
> >=20
> >   [(x, x*2) for x in seq]
> doesn't really change anything, does it?  the (x, x*2) could
> still be a value tuple or an assignment target.

umm.  not sure "assignment target" was the right term here; what
I'm trying to say is that you cannot tell what you're parsing until
you've seen the "for" keyword.

or in other words, the "n" in "when you see 'x', you have to read
'n' more tokens before you can tell what 'x' is" suddenly became
much larger...

(after all, I've successfully parsed Python code with a very simple
non-backtracking recursive-descent parser -- and I'm not sure I
can teach that one to recognize list comprehensions...)

(and yes, I'm sure this can be expressed in [AELRS]+\(\d+\)
notation, but I'm not gonna try ;-)