On Tue, Apr 21, 2020 at 02:33:04PM -0000, Brandt Bucher wrote:
Sure, but I think cases where you want that assumption _checked_ are a lot less common. There are lots of postconditions that you assume just as often as “x, y, and z are fully consumed” and just as rarely want to check, so we don’t need to make it easy to check every possible one of them.
It seems that our experiences differ rather significantly. This isn't a "rare" assumption for me,
Great! Since this is not a rare assumption for you, then you should have no trouble coming up with some concrete examples of how and when you would use it. Because so far in this thread, I've seen no concrete examples, and I cannot think of any. It's not like this has obvious usefulness.
and it's unique because it's one that `zip` already handles internally.
I don't think it does. Here is an obvious case where zip does not check that the iterators are of equal length. Which it could only do by consuming items *after* it hits an empty iterator. Which it does not do: py> a = iter([]) py> b = iter([1]) py> L = list(zip(a, b)) py> next(b) 1 So it seems to me that you are incorrect, zip does not already handle the case of unequal iterators internally.
I know that I, and everyone on my team, would use it frequently!
Use it frequently for what? "We would use it!" is not a use-case. How would you use it? Reading ahead in this thread, I get the impression that you want this to *verify* that your inputs are the same length. If I'm right, then you aren't actually planning on catching and recovering from the exception raised. It's hard to see how you could recover from an exception other than to log the "failure" and then - kill the application; or - proceed as if the truncated zip was all the data you had. The first option, it seems to me, makes for a user-hostile experience. The second, it seems to me, is precisely what zip() does now, without the logging of the "failure". Either way, I don't see what logging the failure gives you. But maybe I don't understand what you intend to do with this feature. By the way, with zero use-cases for this feature so far, I think it is way to early to be opening a bpo issue. -- Steven