On Mon, Mar 28, 2011 at 2:11 PM, Daniel Stutzbach <stutzb...@google.com> wrote:
> Is there a good use-case for the func argument?  I can only think of bad
> use-cases (where "func" does something that does not remotely resemble
> addition).  I fear that people will actually implement these bad use-cases,
> and I will have to try to read and understand their code.
> Adding the func argument seems analogous to adding a func argument to sum(),
> which would give it all of the power of reduce().

The difference lies in the fact that, because accumulate is an
iterator that yields a *running* result, the two corner cases that
make reduce problematic in practice (i.e. correctly handling empty and
1-item input iterables) are handled naturally.

The examples that Raymond gives in the docs (cumulative
multiplication, running min/max, cash flow accumulation) look fairly
solid to me.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
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/archive%40mail-archive.com

Reply via email to