https://github.com/python/cpython/commit/9b14083497f50213f908c1359eeaf47c97161347
commit: 9b14083497f50213f908c1359eeaf47c97161347
branch: main
author: Sergey B Kirpichev <[email protected]>
committer: erlend-aasland <[email protected]>
date: 2024-10-29T08:08:08Z
summary:
Align functools.reduce() docstring with PEP-257 (#126045)
Yak-shave in preparation for Argument Clinic adaption in gh-125999.
files:
M Lib/functools.py
M Modules/_functoolsmodule.c
diff --git a/Lib/functools.py b/Lib/functools.py
index 9d53d3601559b2..27abd622a8cff1 100644
--- a/Lib/functools.py
+++ b/Lib/functools.py
@@ -238,12 +238,14 @@ def reduce(function, sequence, initial=_initial_missing):
"""
reduce(function, iterable[, initial], /) -> value
- Apply a function of two arguments cumulatively to the items of a sequence
- 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
- ((((1+2)+3)+4)+5). If initial is present, it is placed before the items
- of the iterable in the calculation, and serves as a default when the
- iterable is empty.
+ Apply a function of two arguments cumulatively to the items of an
iterable, from left to right.
+
+ This effectively reduces the iterable to a single value. If initial is
present,
+ it is placed before the items of the iterable in the calculation, and
serves as
+ a default when the 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)
diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c
index 802b1cf792c555..da4e088e54621e 100644
--- a/Modules/_functoolsmodule.c
+++ b/Modules/_functoolsmodule.c
@@ -1009,12 +1009,14 @@ functools_reduce(PyObject *self, PyObject *args)
PyDoc_STRVAR(functools_reduce_doc,
"reduce(function, iterable[, initial], /) -> value\n\
\n\
-Apply a function of two arguments cumulatively to the items of a sequence\n\
-or iterable, from left to right, so as to reduce the iterable to a single\n\
-value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates\n\
-((((1+2)+3)+4)+5). If initial is present, it is placed before the items\n\
-of the iterable in the calculation, and serves as a default when the\n\
-iterable is empty.");
+Apply a function of two arguments cumulatively to the items of an iterable,
from left to right.\n\
+\n\
+This effectively reduces the iterable to a single value. If initial is
present,\n\
+it is placed before the items of the iterable in the calculation, and serves
as\n\
+a default when the iterable is empty.\n\
+\n\
+For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5])\n\
+calculates ((((1 + 2) + 3) + 4) + 5).");
/* lru_cache object **********************************************************/
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]