[Python-3000] have zip() raise exception for sequences of different lengths

Raymond Hettinger rhettinger at ewtllc.com
Thu Aug 31 02:03:17 CEST 2006

>Proposed change:
>zip(  	[iterable, ...])
>    This function returns a list of tuples, where the i-th tuple
>contains the i-th element from each of the argument sequences or
>iterables. It is an error if the argument sequences are of different
>That seems pretty comparable in complexity to me.  Could you explain
>how this makes zip() harder to understand?

It's a PITA because it precludes all of the use cases whether the inputs 
ARE intentionally of different length (like when one argument supplys an 
infinite iterator):

   for lineno, ts, line in zip(count(1), timestamp(), sys.stdin):
       print 'Line %d, Time %s:  %s)' % (lineno, ts, line)


More information about the Python-3000 mailing list