map isn't particularly pythonic. I would recommend using list comprehensions instead:

map(f, iterable)

is basically equivalent to:

[f(x) for x in iterable]

map on its own can't do a Cartesian product, because the length of its output list is always the same as its input list. You can trivially do a Cartesian product with a list comprehension though:

[(a, b) for a in iterable_a for b in iterable_b]

The syntax is a little confusing -- that's basically equivalent to:

result = []
for a in iterable_a:
    for b in iterable_b:
        result.append((a, b))
Answer from dave on Stack Overflow
🌐
Python Reference
python-reference.readthedocs.io › en › latest › docs › functions › map.html
map — Python Reference (The Right Way) 0.1 documentation
If one iterable is shorter than another it is assumed to be extended with None items. If function is None, the identity function is assumed; if there are multiple arguments, map() returns a list consisting of tuples containing the corresponding items from all iterables (a kind of transpose ...
🌐
Python documentation
docs.python.org › 3 › library › functions.html
Built-in Functions — Python 3.14.3 documentation
3 weeks ago - Rather than being a function, list is actually a mutable sequence type, as documented in Lists and Sequence Types — list, tuple, range. ... Return a mapping object representing the current local symbol table, with variable names as the keys, and their currently bound references as the values.
🌐
Python
docs.python.org › 3 › c-api › mapping.html
Mapping Protocol — Python 3.14.3 documentation
3.14.3 Documentation » · Python/C API reference manual » · Abstract Objects Layer » · Mapping Protocol · | Theme · Auto · Light · Dark | See also PyObject_GetItem(), PyObject_SetItem() and PyObject_DelItem(). int PyMapping_Check(PyObject *o)¶ · Part of the Stable ABI.
🌐
W3Schools
w3schools.com › python › ref_func_map.asp
Python map() Function
Python Examples Python Compiler ... Python Bootcamp Python Certificate Python Training ... The map() function executes a specified function for each item in an iterable....
🌐
Python Tips
book.pythontips.com › en › latest › map_filter.html
4. Map, Filter and Reduce — Python Tips 0.1 documentation
In 325+ pages, I will teach you ... approach to programming. We will discuss them one by one and understand their use cases. Map applies a function to all the items in an input_list....
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.map.html
pandas.DataFrame.map — pandas 3.0.1 documentation
Added in version 2.1.0: DataFrame.applymap was deprecated and renamed to DataFrame.map. This method applies a function that accepts and returns a scalar to every element of a DataFrame. ... Python function, returns a single value from a single value.
Top answer
1 of 6
529

map isn't particularly pythonic. I would recommend using list comprehensions instead:

map(f, iterable)

is basically equivalent to:

[f(x) for x in iterable]

map on its own can't do a Cartesian product, because the length of its output list is always the same as its input list. You can trivially do a Cartesian product with a list comprehension though:

[(a, b) for a in iterable_a for b in iterable_b]

The syntax is a little confusing -- that's basically equivalent to:

result = []
for a in iterable_a:
    for b in iterable_b:
        result.append((a, b))
2 of 6
99

map doesn't relate to a Cartesian product at all, although I imagine someone well versed in functional programming could come up with some impossible to understand way of generating a one using map.

map in Python 3 is equivalent to this:

def map(func, iterable):
    for i in iterable:
        yield func(i)

and the only difference in Python 2 is that it will build up a full list of results to return all at once instead of yielding.

Although Python convention usually prefers list comprehensions (or generator expressions) to achieve the same result as a call to map, particularly if you're using a lambda expression as the first argument:

[func(i) for i in iterable]

As an example of what you asked for in the comments on the question - "turn a string into an array", by 'array' you probably want either a tuple or a list (both of them behave a little like arrays from other languages) -

 >>> a = "hello, world"
 >>> list(a)
['h', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd']
>>> tuple(a)
('h', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd')

A use of map here would be if you start with a list of strings instead of a single string - map can listify all of them individually:

>>> a = ["foo", "bar", "baz"]
>>> list(map(list, a))
[['f', 'o', 'o'], ['b', 'a', 'r'], ['b', 'a', 'z']]

Note that map(list, a) is equivalent in Python 2, but in Python 3 you need the list call if you want to do anything other than feed it into a for loop (or a processing function such as sum that only needs an iterable, and not a sequence). But also note again that a list comprehension is usually preferred:

>>> [list(b) for b in a]
[['f', 'o', 'o'], ['b', 'a', 'r'], ['b', 'a', 'z']]
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-map-function
Python map() function - GeeksforGeeks
map() function in Python applies a given function to each element of an iterable (list, tuple, set, etc.) and returns a map object (iterator).
Published   September 7, 2025
Find elsewhere
🌐
Real Python
realpython.com › python-map-function
Python's map(): Processing Iterables Without a Loop – Real Python
July 31, 2023 - According to the documentation, map() takes a function object and an iterable (or multiple iterables) as arguments and returns an iterator that yields transformed items on demand.
🌐
Python documentation
docs.python.org › 3 › tutorial › datastructures.html
5. Data Structures — Python 3.14.3 documentation
Another useful data type built into Python is the dictionary (see Mapping Types — dict).
🌐
Programiz
programiz.com › python-programming › methods › built-in › map
Python map() Function
The map() function executes a given function to each element of an iterable (such as lists,tuples, etc.).
🌐
DataCamp
datacamp.com › tutorial › python-map-function
Python map() Function: A Complete Guide | DataCamp
December 10, 2025 - The map() function requires at least two parameters: a callable function and an iterable. Optional additional iterables allow broadcasting the function across zipped sequences, which are perfect for vectorized operations akin to NumPy's apply_along_axis(). In Python 3, map() returns a map object, an iterator subclass, rather than a list...
🌐
GitHub
gist.github.com › 89465127 › 5275551
Examples of map() built-in that follow the official python documentation at http://docs.python.org/2/library/functions.html#map · GitHub
Examples of map() built-in that follow the official python documentation at http://docs.python.org/2/library/functions.html#map - map_example.py
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-map-function
Python map() function | DigitalOcean
August 3, 2022 - Python map() function is used to apply a function on all the elements of specified iterable and return map object. Python map object is an iterator, so we can iterate over its elements. We can also convert map object to sequence objects such as list, tuple etc.
🌐
Python Cheatsheet
pythoncheatsheet.org › home › builtin › map
Python map() built-in function - Python Cheatsheet
The map function, map(function, iterable) takes in one or more iterables, a ‘callback function’ (often a lambda), and returns a “Map Object”. The map object contains the result of the map function applying the callback to each element in the iterable arguments...
🌐
Codecademy
codecademy.com › docs › python › built-in functions › map()
Python | Built-in Functions | map() | Codecademy
March 25, 2022 - The map() built-in function accepts a function and applies it to every item in an iterable. It outputs a map object. ... Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
🌐
Python documentation
docs.python.org › 3 › library › stdtypes.html
Built-in Types — Python 3.14.3 documentation
3 weeks ago - When indexed by a Unicode ordinal (an integer), the table object can do any of the following: return a Unicode ordinal or a string, to map the character to one or more other characters; return None, to delete the character from the return string; or raise a LookupError exception, to map the character to itself.
🌐
Real Python
realpython.com › ref › builtin-functions › map
map() | Python’s Built-in Functions – Real Python
In this example, you use map() to convert a list of temperatures in Celsius into Fahrenheit by applying the to_fahrenheit() function to each item in the input list. ... Learn how Python's map() transforms iterables without loops, and when to use list comprehensions or generators instead.
🌐
Stadia Maps
docs.stadiamaps.com › sdks › python
Official Python SDK - Stadia Maps Documentation
The Stadia Maps Python SDK is the easiest way to access our APIs from Python scripts, notebooks, and server-side applications. The SDK includes docstrings straight from our spec, and editors like PyCharm bring the official docs to your fingertips.
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-use-the-python-map-function
Ultimate Guide to Python Map Function for Data Processing | DigitalOcean
December 18, 2024 - We can use the Python built-in function map() to apply a function to each item in an iterable (like a list or dictionary) and return a new iterator for retrieving the results. map() returns a map object (an iterator), which we can use in other parts of our program.