This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年09月28日 08:55 by chris.jerdonek, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (5) | |||
|---|---|---|---|
| msg171419 - (view) | Author: Chris Jerdonek (chris.jerdonek) * (Python committer) | Date: 2012年09月28日 08:55 | |
> Date: Thu, 6 Sep 2012 20:38:21 +0800 > To: docs@python.org > Subject: [docs] There is bug about the built-in function reduce in the > document > > I found a bug in the document about reduce : > http://docs.python.org/library/functions.html#reduce > > Here is the patch: > def reduce(function, iterable, initializer=None): > it = iter(iterable) > if initializer is None: > try: > initializer = next(it) > except StopIteration: > raise TypeError('reduce() of empty sequence with no initial > value') > accum_value = initializer > - for x in iterable: > + for x in it: > accum_value = function(accum_value, x) > return accum_value > > It duplicated the first element of iterable > > For example: > In [4]: reduce(lambda x,y:x+y, [1,2,3,4]) > Out[4]: 10 > > In [5]: docreduce.reduce(lambda x,y:x+y ,[1,2,3,4]) > Out[5]: 11 (from: http://mail.python.org/pipermail/docs/2012-September/010513.html and http://mail.python.org/pipermail/docs/2012-September/010526.html ) |
|||
| msg171425 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2012年09月28日 09:51 | |
Indeed. Will probably want to add an example with 1-element sequence for functools.reduce in Doc/howto/functional.rst. |
|||
| msg171586 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年09月29日 18:51 | |
New changeset a6779524962c by Chris Jerdonek in branch '2.7': Close issue #16077: fix code example in documentation of reduce() built-in (from docs@). http://hg.python.org/cpython/rev/a6779524962c |
|||
| msg171587 - (view) | Author: Chris Jerdonek (chris.jerdonek) * (Python committer) | Date: 2012年09月29日 18:54 | |
Serhiy, feel free to create a new issue for Doc/howto/functional.rst if you feel an addition there is warranted. |
|||
| msg171591 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2012年09月29日 19:07 | |
I thought and decided it wasn't worth it. Howtos for general cases, and not for corner cases. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:36 | admin | set | github: 60281 |
| 2012年09月29日 19:07:42 | serhiy.storchaka | set | messages: + msg171591 |
| 2012年09月29日 18:54:04 | chris.jerdonek | set | status: open -> closed resolution: fixed messages: + msg171587 stage: needs patch -> resolved |
| 2012年09月29日 18:51:57 | python-dev | set | nosy:
+ python-dev messages: + msg171586 |
| 2012年09月29日 17:53:17 | chris.jerdonek | set | assignee: docs@python -> chris.jerdonek |
| 2012年09月28日 09:51:18 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages: + msg171425 |
| 2012年09月28日 08:55:51 | chris.jerdonek | create | |