2 ms·
I believe masklinn is talking about whether `zip` consumes an extra element from the longer iterator on the last iteration, when the shorter iterator raises Sto
by greenpeas 4y ago
I believe masklinn is talking about whether `zip` consumes an extra element from the longer iterator on the last iteration, when the shorter iterator raises StopIteration. And the behavior might vary depending on the order of the arguments.
def a():
yield "a1"
def b():
yield "b1"
yield "b2"
x,y = a(),b()
zip(x,y) # => [("a1","b1")]
next(x) # => raise StopIteration
next(y) # => "b2"
x,y = a(),b()
zip(y,x) # => [("b1","a1")]
next(x) # => raise StopIteration
next(y) # => raise StopIteration