Replace reduce with listcomprehension?
Luis M. González
luismgz at gmail.com
Tue Aug 26 00:48:33 CEST 2008
I guess the link I provided above is old news...
In the more recent Python 3000 FAQ, GvR says:
Q. If you're killing reduce(), why are you keeping map() and filter()?
A. I'm not killing reduce() because I hate functional programming; I'm
killing it because almost all code using reduce() is less readable
than the same thing written out using a for loop and an accumulator
variable. On the other hand, map() and filter() are often useful and
when used with a pre-existing function (e.g. a built-in) they are
clearer than a list comprehension or generator expression. (Don't use
these with a lambda though; then a list comprehension is clearer and
So it seems only reduce will be eliminated.
More information about the Python-list