Beginner Question : Iterators and zip

cokofreedom at gmail.com cokofreedom at gmail.com
Mon Jul 14 09:16:17 CEST 2008


>
> zip(*vec_list) will zip together all entries in vec_list
> Do be aware that zip stops on the shortest iterable.  So if vec[1] is
> shorter than vec[0] and matches otherwise, your output line will be
> truncated.  Or if vec[1] is longer and vec[0] matches as far as it goes,
> there will be no signal either.
>

Do note that from Python 3.0 there is another form of zip that will
read until all lists are exhausted, with the other being filled up
with a settable default value. Very useful!



More information about the Python-list mailing list