Replace reduce with listcomprehension?
Diez B. Roggisch
deets at nospam.web.de
Mon Aug 25 18:53:35 EDT 2008
Luis M. González schrieb:
> Correction:
> 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
> faster.)
>
> So it seems only reduce will be eliminated.
Nope. From the link you provided yourself:
"""
Only reduce will be removed from the 3.0 standard library. You can
import it from functools.
"""
Diez
More information about the Python-list
mailing list