CKTIS / Python
itertools.starmap
Déplie chaque ligne en arguments positionnels de la fonction à la lecture.
Version : Python 3.14; repository image, production runtime not attested
Syntaxe
itertools.starmap(function, iterable, /)Déplie chaque ligne en arguments positionnels de la fonction à la lecture.
(2, 3) donne pow(2, 3) = 8 et (3, 2) donne 9. Une entrée vide ne déclenche aucun appel.
Une ligne de mauvaise arité lève TypeError à la lecture.
import itertools as I
calls = []
def f(a, b):
calls.append((a, b))
return a + b
it = I.starmap(f, [(2, 3)])
assert not calls and next(it) == 5 and calls == [(2, 3)]
Exemples
import itertools as I
print(list(I.starmap(pow, [(2, 3), (3, 2)])))
print(list(I.starmap(pow, [])))
Résultat
[8, 9] []
Une ligne de mauvaise arité lève TypeError à la lecture.