mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #19202: Add cross-reference and a rough code equivalent
This commit is contained in:
parent
5d4121a631
commit
64801680d3
2 changed files with 15 additions and 0 deletions
|
@ -185,6 +185,18 @@ The :mod:`functools` module defines the following functions:
|
|||
a default when the sequence is empty. If *initializer* is not given and
|
||||
*sequence* contains only one item, the first item is returned.
|
||||
|
||||
Equivalent to::
|
||||
|
||||
def reduce(function, iterable, initializer=None):
|
||||
it = iter(iterable)
|
||||
if initializer is None:
|
||||
value = next(it)
|
||||
else:
|
||||
value = initializer
|
||||
for element in it:
|
||||
value = function(value, element)
|
||||
return value
|
||||
|
||||
|
||||
.. function:: update_wrapper(wrapper, wrapped, assigned=WRAPPER_ASSIGNMENTS, updated=WRAPPER_UPDATES)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue