List Comprehensions Enhancement
Tim Peters
tim_one at email.msn.com
Mon Sep 13 22:37:44 EDT 1999
[Hannah Schroeter, points out that Greg Ewing's list comprehension syntax
is more verbose than Haskell's, and comes to the wrong conclusion <wink>]
[William Tanksley, comes to the right conclusion]
> I actually liked the verbosity a lot. I thought it was extremely cool;
> I'd like to see this in Python, although I suspect it won't make it (it's
> a little too much like a functional language).
This was debated at extraordinary length and in extraordinary detail last
year (or last decade, or some time span long enough ago that I can't
remember quite when -- maybe last week). Guido was kindly disposed toward
it, and for the same reason Haskell fans can never go back to Scheme <wink>:
it can replace almost all common uses of map and filter with much nicer
syntax; and, in Python's case, can be implemented much more efficiently than
map/filter are implemented today, via generating inline nested loops.
So, now that Greg has stopped harassing Guido in his sig <wink>, it stands a
better chance than you may think.
>> Also, I think there should be a clear separator between the
>> generators/predicates in your syntax too:
>>
>> print [(i,s) for i in nums, for s in strs]
>> or similar.
> I agree -- my initial reaction was to put 'and' as the seperator. Amazing
> how great minds think alike :).
A good way to kill it would be to reopen debate about the syntax <0.9
wink -- but finding a thoroughly backward-compatible and unambiguous
spelling isn't easy, and off-the-cuff "gosh, I like the way *this* looks
better" isn't going to succeed>.
>> Nice thing, though :-)
> Oh, amazingly. Thanks, Greg. On a scale of one to ten I'd give it a tim.
Oh, it's not *that* good <wink>.
but-it-is-more-pythonic-than-python-ly y'rs - tim
More information about the Python-list
mailing list