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.

Author chris.jerdonek
Recipients chris.jerdonek, docs@python
Date 2012-09-28.08:55:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1348822552.23.0.324199631114.issue16077@psf.upfronthosting.co.za>
In-reply-to
Content
> 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 )
History
Date User Action Args
2012-09-28 08:55:52chris.jerdoneksetrecipients: + chris.jerdonek, docs@python
2012-09-28 08:55:52chris.jerdoneksetmessageid: <1348822552.23.0.324199631114.issue16077@psf.upfronthosting.co.za>
2012-09-28 08:55:51chris.jerdoneklinkissue16077 messages
2012-09-28 08:55:51chris.jerdonekcreate