Closed Gobot1234 closed 10 months ago
Python iterators are forward iterators and are generally not reversible unless one run them to exhaustion while collecting the items in a list and reversing the list. list(reversed(list(zip((1,2), (3,4))))) == [(2, 4), (1, 3)]
. A zip, as an iterator, is nothing special in this regard. So the request does not make much sense.
If an iterator is, in a particular case, based on one or more reversible iterables, then in some cases one might in effect reverse the iterator by reversing the iterables, as you did. Builtins map and filter and some of the itertools iterators can also be reversed this way. But what is special about iterators based on multiple iterables, like zip, is the need for all input iterables to yield the same number of items for reversing them to give the expected result. And there is no way to determine equal length without running the underlying iterables.
I think that this issue should be closed.
This is a minor feature, which does not need previous discussion elsewhere
I disagree -- unless this was already discussed and refined on discuss.python.org (in the Ideas topic) this does not have much of a chance of getting added.
Feature or enhancement
Proposal:
But individually
works
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response