Modules for inclusion in standard library?

Steven Bethard steven.bethard at gmail.com
Wed Jun 29 16:11:20 EDT 2005


Noah wrote:
> def unzip(list):
>     if len(list) == 0: return ()
>     l = []
>     for t in range(len(list[0])):
>         l.append(map( lambda x,t=t: x[t], list ))
>     return tuple(l)

The simplest solution to this problem that I know of:

     def unzip(iterable):
         return zip(*iterable)

However, Guido feels that this is an abuse of the argument passing 
machinery.  For a version that is a little more careful in the case of 
iterables, see:

     http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/302325

STeVe



More information about the Python-list mailing list