Good point. It would have to be dependent on position. In other words, you would never pass an iterator into zip with any expectation that it would be in a usable condition by the time it's done.
Actually, I can't think of any current scenario in which someone would want to do this, with the existing zip logic.
On Apr 20, 2020, at 10:42, Ram Rachum <ram@rachum.com> wrote:
>
> Here's something that would have saved me some debugging yesterday:
>
> >>> zipped = zip(x, y, z, strict=True)
>
> I suggest that `strict=True` would ensure that all the iterables have been exhausted, raising an exception otherwise.
One quick bikeshedding question (which also gets to the heart of how you’d want to implement it); apologies if this came up in the thread from 2 years ago or the discussion in the more-iterables PR that I just suggested everyone should read before commenting, but I wanted to get this down before I forget it.
x = iter(range(5))
y = [0]
try:
zipped = zip(x, y, strict=True)
except ValueError: # assuming that’s the exception you want?
print(next(x))
Should this print 1 or 2 or raise StopIteration or be a don’t-care?
Should it matter if you zip(y, x, strict=True) instead?