CKTIS / Python
itertools.starmap
Entpackt beim Abruf jede Zeile in Positionsargumente der Funktion.
Version: Python 3.14; repository image, production runtime not attested
Syntax
itertools.starmap(function, iterable, /)Entpackt beim Abruf jede Zeile in Positionsargumente der Funktion.
(2, 3) ergibt pow(2, 3) = 8, (3, 2) ergibt 9. Leere Eingabe ruft die Funktion nie auf.
Eine Zeile mit unpassender Argumentanzahl löst erst beim Abruf TypeError aus.
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)]
Beispiele
import itertools as I
print(list(I.starmap(pow, [(2, 3), (3, 2)])))
print(list(I.starmap(pow, [])))
Ergebnis
[8, 9] []
Eine Zeile mit unpassender Argumentanzahl löst erst beim Abruf TypeError aus.