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 Mon, Apr 20, 2020, 23:34 Andrew Barnert <abarn...@yahoo.com> wrote: > On Apr 20, 2020, at 10:42, Ram Rachum <r...@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? > > >
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/2LLTIGGJYT4VC5CH6GPT3LMOBYX6SUDJ/ Code of Conduct: http://python.org/psf/codeofconduct/