map/filter/reduce/lambda opinions and background unscientific mini-survey

Tom Anderson twic at urchin.earth.li
Wed Jul 6 15:38:31 CEST 2005


On Wed, 6 Jul 2005, Terry Hancock wrote:

> On Tuesday 05 July 2005 03:43 pm, Tom Anderson wrote:
>
>> I understand that the backslash is popular in some ivory-tower 
>> functional languages. Currently, a backslash can be used for explicit 
>> line joining, and is illegal elsewhere on a line outside a string 
>> literal, so i think it's available for this. It would be utterly 
>> unpythonic to use puntuation instead of a keyword, and it would make no 
>> sense to novices, but it would scare the crap out of C programmers, 
>> which has to be worth something.
>
> With list comprehensions and generators becoming so integral, I'm
> not sure about "unpythonic".

I'm going to resist the temptation to argue that list comps are themselves 
unpythonic :).

Hang on, where's the punctuation in either of those? They *are* done with 
keywords! A generator is just a function with "yield" instead of "return", 
list comprehensions are just list literals where the explicit sequence of 
items is replaced with code producing them, using the keywords "for", "in" 
and "if", and a generator expression is a list comp *without any 
punctuation!*

> And a syntax just occured to me -- what about this:
>
> [y*x for x,y]
>
> ?

Terrible. Square brackets mean a list, and a lambda is not anything like a 
list.

I see where you're coming from, though; a lambda is a lot like the first 
half of a list comp that's broken off and is roaming free. I can't think 
of a good syntax for it, though.

tom

-- 
find porn apricot



More information about the Python-list mailing list