Antoine Pitrou added the comment:
I agree with Raymond. Examples in the code are not meant to be a reference but,
well, examples. That is, the educational value should come first and strict
adherence to the language spec only second.
Roughly equivalent is already used in the functools doc, it
Roundup Robot added the comment:
New changeset 0b3d69f15950 by Raymond Hettinger in branch '3.4':
Issue #23049: Pure python equivalent shouldn't imply more exactitude than is
really there.
https://hg.python.org/cpython/rev/0b3d69f15950
--
nosy: +python-dev
Changes by Raymond Hettinger raymond.hettin...@gmail.com:
--
resolution: - fixed
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23049
___
Changes by Berker Peksag berker.pek...@gmail.com:
--
stage: needs patch - resolved
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23049
___
___
Serhiy Storchaka added the comment:
I think it would be good to add Python implementation in functools.py and test
they equivalence in tests.
--
nosy: +serhiy.storchaka
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23049
Terry J. Reedy added the comment:
Background: the OP of #19202 proposed equivalent code for all the functool
functions, including two versions for reduce. Georg combined the two versions
into the one that Raymond pushed. Both agreed that reduce was the only
function that really needed this.
Raymond Hettinger added the comment:
Elsewhere I have used rough equivalent.
FWIW, the initializer defaulting to None is also an approximation. It would
be more technically correct to have initializer = sentinel where sentinel =
object(). But of course this too would obfuscate the
New submission from Terry J. Reedy:
from functools import reduce
def add(a,b): return a+b
reduce(add, {})
Traceback (most recent call last):
File C:\Programs\Python34\tem.py, line 3, in module
reduce(add, {})
TypeError: reduce() of empty sequence with no initial value
However, the
Changes by Raymond Hettinger raymond.hettin...@gmail.com:
--
assignee: docs@python - rhettinger
nosy: +rhettinger
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23049
___