
"Guido van Rossum" <guido@python.org> wrote in message news:200310201815.h9KIFM821583@12-236-54-216.client.attbi.com...
Most of us seem to agree that having list comprehensions available as a replacement for map() and filter() is a good thing. But what about reduce()? Are there equally strong reasons for wanting an alternative to that, too? If not, why not?
If anything, the desire there is *more* pressing. Except for operator.add, expressions involving reduce() are notoriously hard to understand (except to experienced APL or Scheme hackers :-).
Things like sum, max, average etc. are expressed very elegantly with iterator comprehensions.
I think the question is more one of frequency of use. List comps have nothing over e.g.
result = [] for x in S: result.append(x**2)
except compactness of exprssion. How frequent is
result = 0.0 for x in S: result += x**2
???
(I've already said my -1 about your 'sum of ...' proposal.)
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/python-python-dev%40m.gman...