diff options
author | Zackery Spytz <zspytz@gmail.com> | 2020-06-28 06:40:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-28 06:40:54 (GMT) |
commit | cd3c2bdd5d53db7fe1d546543d32000070916552 (patch) | |
tree | d819bf1020055af6da2e3ab84a97bb6d36d9eeb0 /Lib/functools.py | |
parent | 8ab77c6f9fb6ef86af8f6b8722a2fcb37438edd0 (diff) | |
download | cpython-cd3c2bdd5d53db7fe1d546543d32000070916552.zip cpython-cd3c2bdd5d53db7fe1d546543d32000070916552.tar.gz cpython-cd3c2bdd5d53db7fe1d546543d32000070916552.tar.bz2 |
bpo-31082: Use "iterable" in the docstring for functools.reduce() (GH-20796)
Diffstat (limited to 'Lib/functools.py')
-rw-r--r-- | Lib/functools.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Lib/functools.py b/Lib/functools.py index 5cab497..b1f1fe8 100644 --- a/Lib/functools.py +++ b/Lib/functools.py @@ -236,14 +236,14 @@ _initial_missing = object() def reduce(function, sequence, initial=_initial_missing): """ - reduce(function, sequence[, initial]) -> value + reduce(function, iterable[, initial]) -> value - Apply a function of two arguments cumulatively to the items of a sequence, - from left to right, so as to reduce the sequence to a single value. - For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates + 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 sequence in the calculation, and serves as a default when the - sequence is empty. + of the iterable in the calculation, and serves as a default when the + iterable is empty. """ it = iter(sequence) @@ -252,7 +252,8 @@ def reduce(function, sequence, initial=_initial_missing): try: value = next(it) except StopIteration: - raise TypeError("reduce() of empty sequence with no initial value") from None + raise TypeError( + "reduce() of empty iterable with no initial value") from None else: value = initial |