summaryrefslogtreecommitdiffstats
path: root/Lib/functools.py
diff options
context:
space:
mode:
authorSergey B Kirpichev <skirpichev@gmail.com>2024-10-29 08:08:08 (GMT)
committerGitHub <noreply@github.com>2024-10-29 08:08:08 (GMT)
commit9b14083497f50213f908c1359eeaf47c97161347 (patch)
treec01bd1de364f4123235d5c2bae28cdb99cebfa8e /Lib/functools.py
parentaeafaf4cda5bfce44bb054b4c530696901646abe (diff)
downloadcpython-9b14083497f50213f908c1359eeaf47c97161347.zip
cpython-9b14083497f50213f908c1359eeaf47c97161347.tar.gz
cpython-9b14083497f50213f908c1359eeaf47c97161347.tar.bz2
Align functools.reduce() docstring with PEP-257 (#126045)
Yak-shave in preparation for Argument Clinic adaption in gh-125999.
Diffstat (limited to 'Lib/functools.py')
-rw-r--r--Lib/functools.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/Lib/functools.py b/Lib/functools.py
index 9d53d36..27abd62 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)