Reverse zip() ?

Casey McGinty casey.mcginty at gmail.com
Wed Dec 3 16:48:10 EST 2008


> The corner case is when dealing with empty lists and there aren't
> enough items to unpack.
>
>
Another solution to zip(), with a slightly different behaviour for conner
cases ....

>>> a = (1,2,3)
>>> b = (1,2,3)
>>> c = (1,2,3,4)
>>> zip(a,b)
[(1, 1), (2, 2), (3, 3)]
>>> map(None,a,b)
[(1, 1), (2, 2), (3, 3)]
>>> zip(a,c)
[(1, 1), (2, 2), (3, 3)]
>>> map(None,a,c)
[(1, 1), (2, 2), (3, 3), (None, 4)]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20081203/37eb25fc/attachment-0001.html>


More information about the Python-list mailing list