CKTIS / Python
map()
Llama bajo demanda a la función con un argumento posicional de cada entrada.
Versión: Python 3.14; repository image, production runtime not attested
Sintaxis
map(function, iterable, /, *iterables, strict=False)Llama bajo demanda a la función con un argumento posicional de cada entrada.
Las listas solo forman pow(2, 4), es decir 16, porque se agota la segunda.
Python 3.14 añadió strict=True que provoca ValueError durante la lectura si las longitudes difieren.
it = map(pow, [2, 3], [4], strict=True)
assert next(it) == 16
try:
next(it)
except ValueError:
pass
else:
raise AssertionError
Ejemplos
print(list(map(pow, [2, 3], [4])))
try:
list(map(pow, [2, 3], [4], strict=True))
except ValueError as error:
print(type(error).__name__)
Resultado
[16] ValueError
Python 3.14 añadió strict=True que provoca ValueError durante la lectura si las longitudes difieren.