On this page
map
Prev: locals | Up: __builtins__ | Next: max
Rel: all, any, enumerate, filter, iter
Ref: docs.python.org — map
Tags: #public #python3 #builtins
Import & Availability
# Built-in (available globally without import)
from builtins import map
Overview & Signature
map(function, iterable, /, *iterables, strict=False)
Make an iterator that computes the function using arguments from each of the iterables. Stops when the shortest iterable is exhausted.
Usage
assert list(map(str.upper, ["a", "b"])) == ["A", "B"]
assert list(map(pow, [2, 3, 4], [3, 2, 1])) == [8, 9, 4]
Gotchas
- Lazy iterator stopping at the shortest iterable: Great with existing callables (
map(int, tokens)); prefer a generator expression when you'd otherwise write alambda.
REPL Inspect
help(map)
Linked from
Related notes
- tuts/python3/__builtins__/__builtins__ Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/locals Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/max Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__ links to this page; shared tags: #builtins
- tuts/python3/__builtins__/all Linked here; shared tags: #builtins
- tuts/python3/__builtins__/any Linked here; shared tags: #builtins
- tuts/python3/__builtins__/enumerate Linked here; shared tags: #builtins
- tuts/python3/__builtins__/filter Linked here; shared tags: #builtins
- tuts/python3/__builtins__/iter Linked here; shared tags: #builtins
- tuts/c/builtins shared tags: #builtins