On Tue, 21 Apr 2020 at 16:28, Dan Sommers <2QdxY4RzWzUUiLuE@potatochowder.com> wrote:
On Tue, 21 Apr 2020 16:05:54 +0100 Paul Moore <p.f.moore@gmail.com> wrote:
To be clear - would you catch the error in your code? What would you do when it was raised? Or are you simply wanting, in effect, an assert when some iterables remain unexhausted? Because I can imagine that wanting builtins to assert when their preconditions are untrue is something that might be considered a more common desire - but it's a much wider change in design philosophy than just zip().
Picking a nit, this has to be a post condition rather than a precondition, because you can't tell how long an iterator is without consuming it.
No, I view it as a precondition. All of the supplied iterables must be the same length. And yes, that's precisely the issue, you can't actually check that precondition, so you have to assert later when you find that it was violated. My assumption is that people wanting "strict" behaviour are actually just looking for a way to error out if that precondition is violated, and because then can't check in advance, they need the zip function to complain if one of the inputs ends early. Hence my suggestion that maybe it's not so much an (actionable) exception that people want as an assertion. Paul