diff options
author | Sayandip Dutta <sayandip199309@gmail.com> | 2024-11-12 13:11:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-12 13:11:58 (GMT) |
commit | abb90ba46c597a1b192027e914ad312dd62d2462 (patch) | |
tree | aead09786185ca070d9f05c6ea4d91b772830ef2 /Doc/library | |
parent | 6e3bb8a91380ba98d704f2dca8e98923c0abc8a8 (diff) | |
download | cpython-abb90ba46c597a1b192027e914ad312dd62d2462.zip cpython-abb90ba46c597a1b192027e914ad312dd62d2462.tar.gz cpython-abb90ba46c597a1b192027e914ad312dd62d2462.tar.bz2 |
gh-125916: Allow functools.reduce() 'initial' to be a keyword argument (#125917)
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/functools.rst | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst index e26a222..a9aceee 100644 --- a/Doc/library/functools.rst +++ b/Doc/library/functools.rst @@ -453,7 +453,7 @@ The :mod:`functools` module defines the following functions: .. versionadded:: 3.4 -.. function:: reduce(function, iterable[, initial], /) +.. function:: reduce(function, iterable, /[, initial]) Apply *function* of two arguments cumulatively to the items of *iterable*, from left to right, so as to reduce the iterable to a single value. For example, @@ -468,7 +468,7 @@ The :mod:`functools` module defines the following functions: initial_missing = object() - def reduce(function, iterable, initial=initial_missing, /): + def reduce(function, iterable, /, initial=initial_missing): it = iter(iterable) if initial is initial_missing: value = next(it) @@ -481,6 +481,9 @@ The :mod:`functools` module defines the following functions: See :func:`itertools.accumulate` for an iterator that yields all intermediate values. + .. versionchanged:: next + *initial* is now supported as a keyword argument. + .. decorator:: singledispatch Transform a function into a :term:`single-dispatch <single |