[Python-Dev] list comprehensions again...
Gordon McMillan
gmcm@hypernet.com
Tue, 11 Jul 2000 17:47:56 -0400
Barry A. Warsaw wrote:
> Sorry, but I'm being to think that both the list comprehensions
> and parallel for loops are looking pretty dodgy.
I'm with Barry here (despite the public humiliation the
association involves).
My expectations (from examples) correlates to accompanying
explanations no better than random choice. I *thought* I liked
Greg Ewing's original proposal, but at this point I see
syntactic salts of ammonia around one very clear idiom
(nested fors) and one less intuitive but unambiguous idiom
(map).
I like the set notation, but there's a big impedance mismatch
to Python. I'd be tempted to spell "cartesian product" as a
product.
To put it another way:
- syntactic sugar for nested "for" loops would be nice, but
there's no crying need for it
- the current spelling of parallel loops is awkward and
probably does warrant syntactic sugar (despite Greg Wilson's
experiment that it's not what's expected).
If list comprehensions are going to do *both*, the difference in
how they're spelled will have to be obvious and intuitive, or we
might as well just keep explaining how to use map.
- Gordon