mirror of https://github.com/python/cpython
[3.13] Align functools.reduce() docstring with PEP-257 (GH-126045) (#126113)
Yak-shave in preparation for Argument Clinic adaption in gh-125999.
(cherry picked from commit 9b14083497
)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
This commit is contained in:
parent
36f8184d29
commit
e7c63107d1
|
@ -239,12 +239,14 @@ def reduce(function, sequence, initial=_initial_missing):
|
||||||
"""
|
"""
|
||||||
reduce(function, iterable[, initial], /) -> value
|
reduce(function, iterable[, initial], /) -> value
|
||||||
|
|
||||||
Apply a function of two arguments cumulatively to the items of a sequence
|
Apply a function of two arguments cumulatively to the items of an iterable, from left to right.
|
||||||
or iterable, from left to right, so as to reduce the iterable to a single
|
|
||||||
value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates
|
This effectively reduces the iterable to a single value. If initial is present,
|
||||||
((((1+2)+3)+4)+5). If initial is present, it is placed before the items
|
it is placed before the items of the iterable in the calculation, and serves as
|
||||||
of the iterable in the calculation, and serves as a default when the
|
a default when the iterable is empty.
|
||||||
iterable is empty.
|
|
||||||
|
For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5])
|
||||||
|
calculates ((((1 + 2) + 3) + 4) + 5).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
it = iter(sequence)
|
it = iter(sequence)
|
||||||
|
|
|
@ -780,12 +780,14 @@ Fail:
|
||||||
PyDoc_STRVAR(functools_reduce_doc,
|
PyDoc_STRVAR(functools_reduce_doc,
|
||||||
"reduce(function, iterable[, initial], /) -> value\n\
|
"reduce(function, iterable[, initial], /) -> value\n\
|
||||||
\n\
|
\n\
|
||||||
Apply a function of two arguments cumulatively to the items of a sequence\n\
|
Apply a function of two arguments cumulatively to the items of an iterable, from left to right.\n\
|
||||||
or iterable, from left to right, so as to reduce the iterable to a single\n\
|
\n\
|
||||||
value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates\n\
|
This effectively reduces the iterable to a single value. If initial is present,\n\
|
||||||
((((1+2)+3)+4)+5). If initial is present, it is placed before the items\n\
|
it is placed before the items of the iterable in the calculation, and serves as\n\
|
||||||
of the iterable in the calculation, and serves as a default when the\n\
|
a default when the iterable is empty.\n\
|
||||||
iterable is empty.");
|
\n\
|
||||||
|
For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5])\n\
|
||||||
|
calculates ((((1 + 2) + 3) + 4) + 5).");
|
||||||
|
|
||||||
/* lru_cache object **********************************************************/
|
/* lru_cache object **********************************************************/
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue