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

Steven Bethard steven.bethard at gmail.com
Wed Aug 30 23:40:55 CEST 2006


A couple Python-3000 threads [1] [2] have indicated that the most
natural use of zip() is with sequences of the same lengths.  I feel
the same way, and run into this all the time.  Because the error would
otherwise pass silently, I usually end up adding checks before each
use of zip() to raise an exception if I accidentally pass in sequences
of different lengths.

Any chance that zip() in Python 3000 could automatically raise an
exception if the sequence lengths are different?  If there's really a
need for a zip that just truncates, maybe that could be moved to
itertools?  I think the equal-length scenario is dramatically more
common, and keeping that error from passing silently would be a good
thing IMHO.

[1] http://mail.python.org/pipermail/python-3000/2006-March/000160.html
[2] http://mail.python.org/pipermail/python-3000/2006-August/003094.html

Steve
-- 
I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
        --- Bucky Katt, Get Fuzzy


More information about the Python-3000 mailing list