]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] Align functools.reduce() docstring with PEP-257 (GH-126045) (#126113)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 29 Oct 2024 09:13:35 +0000 (10:13 +0100)
committerGitHub <noreply@github.com>
Tue, 29 Oct 2024 09:13:35 +0000 (10:13 +0100)
Yak-shave in preparation for Argument Clinic adaption in gh-125999.

(cherry picked from commit 9b14083497f50213f908c1359eeaf47c97161347)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Lib/functools.py
Modules/_functoolsmodule.c

index d04957c555295e41ed221f856bbf5a5a45e0dd6f..e0140e84842a7dafd478401389b72390d39a22f9 100644 (file)
@@ -239,12 +239,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)
index 564c271915959adbe69d1d9c578ed08eebef4227..9e140a1a580832e052178262cf07856754a474c3 100644 (file)
@@ -780,12 +780,14 @@ Fail:
 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 **********************************************************/