On Tue, 21 Apr 2020 at 16:28, Dan Sommers
<2qdxy4rzwzuui...@potatochowder.com> wrote:
>
> On Tue, 21 Apr 2020 16:05:54 +0100
> Paul Moore <p.f.mo...@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
_______________________________________________
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/2736E53QH2NJEVCQ3SLSFRJXVX4OXKSF/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to