why tar is strange
m.faassen at vet.uu.nl
Thu May 25 14:31:38 CEST 2000
Edward S. Vinyard <vinyard at arlut.utexas.edu> wrote:
> On 23 May 2000, Martijn Faassen wrote:
>>I never used that. 'for' loops are generally more clean and more
>>extensible in Python. I only find myself using map() rarely, filter()
>>even more rarely, and reduce() hardly at all. Of course your mileage may
> How are 'for' loops more extensible in Python?
When you do a map(), you can either call an existing function, or use
lambda. If you can alter the existing function that you call from
mamp(), map can be extended fairly easily. Ofter you're calling a
library function or a builtin function however, or you're using
lambda. Neither of these can be easily extended with new functionality.
When you have a for() loop that calls a library function, it's easy to
add a few extra statements when you want to extend the behavior of the
for loop. Perhaps you want to count something. Perhaps you want to break
from the loop early in some cases. It's all easy if you started out
with a for loop.
That's what I mean with 'more extensible'; of course you can swap from
map() to a for loop when it becomes necessary, but I prefer having the
loop there already, myself.
>>I think Guido's idea here is you shouldn't use those a lot anyway. It's
>>said he rather regrets adding 'lambda' to the language, after all. Not
>>that this kind of functional programming can't be fun.
> Why should we avoid these functions?
I think the idea is that lambda looks ugly, and is harder to extend
cleanly (and there's no lexical scoping and hacks to get around it, etc).
I'm not saying you should *avoid* map() and friends, just that perhaps the
general patterna would be that you don't use them a lot. Of course your
mileage, as said before, may vary.
History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?
More information about the Python-list