diff options
author | Nice Zombies <nineteendo19d0@gmail.com> | 2024-11-04 14:00:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-04 14:00:19 (GMT) |
commit | 3032fcd90ecb745b737cbc93f694f9a802062a3a (patch) | |
tree | 24708afe3029ea00fd9ef72e0295593a90168f5d /Doc/library | |
parent | bfc1d2504c183a9464e65c290e48516d176ea41f (diff) | |
download | cpython-3032fcd90ecb745b737cbc93f694f9a802062a3a.zip cpython-3032fcd90ecb745b737cbc93f694f9a802062a3a.tar.gz cpython-3032fcd90ecb745b737cbc93f694f9a802062a3a.tar.bz2 |
gh-119793: Add optional length-checking to `map()` (GH-120471)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/functions.rst | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 03fc41f..a7549b9 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1205,14 +1205,19 @@ are always available. They are listed here in alphabetical order. unchanged from previous versions. -.. function:: map(function, iterable, *iterables) +.. function:: map(function, iterable, /, *iterables, strict=False) Return an iterator that applies *function* to every item of *iterable*, yielding the results. If additional *iterables* arguments are passed, *function* must take that many arguments and is applied to the items from all iterables in parallel. With multiple iterables, the iterator stops when the - shortest iterable is exhausted. For cases where the function inputs are - already arranged into argument tuples, see :func:`itertools.starmap`\. + shortest iterable is exhausted. If *strict* is ``True`` and one of the + iterables is exhausted before the others, a :exc:`ValueError` is raised. For + cases where the function inputs are already arranged into argument tuples, + see :func:`itertools.starmap`. + + .. versionchanged:: 3.14 + Added the *strict* parameter. .. function:: max(iterable, *, key=None) |