[Python-Dev] Re: PEP 618: Add Optional Length-Checking To zip

2020年6月02日 06:48:16 -0700

On 02Jun2020 1430, David Mertz wrote:
On Tue, Jun 2, 2020 at 8:07 AM Chris Angelico <[email protected] <mailto:[email protected]>> wrote:
 > Given that the only input parameters are the iterables
 themselves, it's a stretch to even consider the first two as
 possibilities.
 Why? I can conceivably imagine that zip(iter1, iter2, truncate=5)
 would consume at most 5 elements from each iterable. It's not much of
 a stretch. It doesn't happen to be what's proposed, but it's a
 reasonable interpretation. (Though then the default would probably be
 truncate=None to not truncate.)
This was exactly my thought, that Chris wrote very well. I can easily imagine a 'truncate=5' behavior. In fact, if it existed, it is something I would have used multiple times. As is, I use islice() or a break inside a loop, but that hypothetical parameter might be a helpful convenience.
However, it is indeed NOT the current proposal or discussion.
Besides, "zip(iter1, iter2, range(5))" is the same length once you include the extra unpack, plus it works well with earlier versions.
Cheers,
Steve
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/H2D7KJNOSTBORG5BT22JX3XTRG5AATO6/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to