CKTIS / Python
map()
Chama a função a pedido com um argumento posicional de cada entrada.
Versão: Python 3.14; repository image, production runtime not attested
Sintaxe
map(function, iterable, /, *iterables, strict=False)Chama a função a pedido com um argumento posicional de cada entrada.
As listas só formam pow(2, 4), ou seja 16, porque a segunda termina.
O Python 3.14 acrescentou strict=True que gera ValueError durante a leitura quando os comprimentos diferem.
it = map(pow, [2, 3], [4], strict=True)
assert next(it) == 16
try:
next(it)
except ValueError:
pass
else:
raise AssertionError
Exemplos
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
O Python 3.14 acrescentou strict=True que gera ValueError durante a leitura quando os comprimentos diferem.