[issue16077] fix code example in docs for built-in reduce()

2012-09-29 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I thought and decided it wasn't worth it. Howtos for general cases, and not for 
corner cases.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16077] fix code example in docs for built-in reduce()

2012-09-29 Thread Chris Jerdonek

Chris Jerdonek added the comment:

Serhiy, feel free to create a new issue for Doc/howto/functional.rst if you 
feel an addition there is warranted.

--
resolution:  -> fixed
stage: needs patch -> committed/rejected
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16077] fix code example in docs for built-in reduce()

2012-09-29 Thread Roundup Robot

Roundup Robot added the comment:

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

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16077] fix code example in docs for built-in reduce()

2012-09-29 Thread Chris Jerdonek

Changes by Chris Jerdonek :


--
assignee: docs@python -> chris.jerdonek

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16077] fix code example in docs for built-in reduce()

2012-09-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Indeed.

Will probably want to add an example with 1-element sequence for 
functools.reduce in Doc/howto/functional.rst.

--
nosy: +storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16077] fix code example in docs for built-in reduce()

2012-09-28 Thread Chris Jerdonek

New submission from Chris Jerdonek:

> Date: Thu, 6 Sep 2012 20:38:21 +0800
> To: d...@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 )

--
assignee: docs@python
components: Documentation
keywords: easy
messages: 171419
nosy: chris.jerdonek, docs@python
priority: normal
severity: normal
stage: needs patch
status: open
title: fix code example in docs for built-in reduce()
type: enhancement
versions: Python 2.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com