[Python-Dev] [Python-checkins] cpython: Add optional *func* argument to itertools.accumulate().
Daniel Stutzbach
stutzbach at google.com
Mon Mar 28 06:11:04 CEST 2011
More information about the Python-Dev mailing list
Mon Mar 28 06:11:04 CEST 2011
- Previous message: [Python-Dev] Python 2.7 on Irix 6.5.22 fails ctypes callback test
- Next message: [Python-Dev] [Python-checkins] cpython: Add optional *func* argument to itertools.accumulate().
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sun, Mar 27, 2011 at 6:52 PM, raymond.hettinger < python-checkins at python.org> wrote: > -.. function:: accumulate(iterable) +.. function:: accumulate(iterable[, func]) > > Make an iterator that returns accumulated sums. Elements may be any > addable > - type including :class:`Decimal` or :class:`Fraction`. Equivalent to:: > + type including :class:`Decimal` or :class:`Fraction`. If the optional > + *func* argument is supplied, it should be a function of two arguments > + and it will be used instead of addition. > 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(). -- Daniel Stutzbach -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20110327/2ae6aa76/attachment.html>
- Previous message: [Python-Dev] Python 2.7 on Irix 6.5.22 fails ctypes callback test
- Next message: [Python-Dev] [Python-checkins] cpython: Add optional *func* argument to itertools.accumulate().
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list