Python Forum

Full Version: Did you know that map() accepts more than one iterable?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I read the changelog of Python 3.14-dev: https://docs.python.org/3.14/whatsnew/3....ge-changes and fond something interesting:

Quote:The map() built-in now has an optional keyword-only strict flag like zip() to check that all the iterables are of equal length. (Contributed by Wannes Boeykens in gh-119793.)

The docs of Python 3.13: https://docs.python.org/3/library/functions.html#map
Quote:map(function, iterable, *iterables)

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 itertools.starmap().

Happy coding
Yes I knew that, although I almost never use this feature.
Hi,

yes, I knew that. It's not new at all - Python 2.7. and 3.0 already had it (https://docs.python.org/2.7/library/functions.html#map), so I guess this functionality is even older. But I hardly use it, too.

Regards, noisefloor