[Python-Dev] RE: list comprehensions (was parsers and compilers for 2.0)
Mon, 14 Aug 2000 07:57:13 +0200
Well, Tim, thanx for that mini-PEP, if I can call your recap of years of
discussion that ;-) It did clear up my mind, though I have a few comments to
make. This is the last I have to say about it, though, I didn't intend to
drag you into a new long discussion ;)
On Sun, Aug 13, 2000 at 08:08:45PM -0400, Tim Peters wrote:
> Guido feels exactly the opposite: the business about "alien, forced feel,
> not fitting" is exactly what he's said about map/filter/reduce/lambda on
> many occasions.
Note that I didn't mention lambda, and did so purposely ;) Yes, listcomps
are much better than lambda. And I'll grant the special case of 'None' as
the function is unpythonic, in map/filter/reduce. Other than that, they're
just functions, which I hope aren't too unpythonic<wink>
> > [((a,b)*c, (spam(d)%34)^e) for a in [(x, y) for x in L for y in
> > S] for b in [b for b in B if mean(b)] for b,c in C for a,d in D
> > for e in [Egg(a, b, c, d, e) for e in E]]
> That isn't a serious argument, to my eyes.
Well, it's at the core of my doubts :) 'for' and 'if' start out of thin air.
I don't think any other python statement or expression can be repeated and
glued together without any kind of separator, except string literals (which
I can see the point of, but scared me a little none the less.)
I don't know enough lisp to write this expression in that, but I assume you
could still match the parentheses to find out how they are grouped.
> I know you missed that possibility above because, despite your claim of
> being hard to parse, it's dead easy to spot where your listcomps begin: "["
> is easy for the eye to find.
That's the start of a listcomp, but not of a specific listcomp-for or -if.
> > I hope anyone writing something like that (notice the shadowing of
> > some of the outer vrbls in the inner loops)
> You can find the same in nested lambdas littering map/reduce/etc today.
Yes, and wasn't the point to remove those ? <wink>
Like I said, I'm not arguing against listcomprehensions, I'm just saying I'm
sorry we didn't get yet another debate on syntax ;) Having said that, I'll
step back and let Eric's predicted doom fall over Python; hopefully we are
wrong and you all are right :-)
Thomas Wouters <email@example.com>
Hi! I'm a .signature virus! copy me into your .signature file to help me spread!