Python Forum
Did you know that map() accepts more than one iterable?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Did you know that map() accepts more than one iterable?
#1
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
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#2
Yes I knew that, although I almost never use this feature.
« We can solve any problem by introducing an extra level of indirection »
Reply
#3
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question TypeError: argument of type 'NoneType' is not iterable Tajaldeen 7 2,400 Nov-29-2024, 09:45 AM
Last Post: Tajaldeen
  cmath.rect accepts a negative modulus JMB 2 1,242 Jan-17-2024, 08:00 PM
Last Post: JMB
  function accepts infinite parameters and returns a graph with those values edencthompson 0 1,336 Jun-10-2022, 03:42 PM
Last Post: edencthompson
Question how to solve `'TypeError: 'int' object is not iterable`? netanelst 2 2,821 May-24-2022, 12:03 PM
Last Post: deanhystad
  Trying to understand how isinstance(values, collections.Iterable) work. quazirfan 7 6,589 Aug-10-2021, 08:10 AM
Last Post: snippsat
  Cannot unpack non-iterable NoneType object, i would like to ask for help on this. Jadiac 3 11,362 Oct-18-2020, 02:11 PM
Last Post: Jadiac
  Why the result of "extended iterable unpacking" with set() is unpredictable? zohanlin 2 2,811 Jun-29-2020, 10:30 AM
Last Post: zohanlin
  TypeError: 're.Match' object is not iterable charlesauspicks 1 13,821 May-25-2020, 06:14 AM
Last Post: bowlofred
  function/nonetype object is not iterable nanok66 5 6,107 May-08-2020, 07:39 PM
Last Post: nanok66
  min() function in iterable index OokaydO 4 3,983 Apr-23-2020, 09:21 AM
Last Post: OokaydO

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020