A really bad idea.

François Pinard pinard at iro.umontreal.ca
Fri Nov 15 08:20:01 EST 2002


[Carl Banks]

> Paul Foley wrote:
> > On Thu, 14 Nov 2002 15:33:33 -0800, Russell E Owen wrote:
> > 
> >> On the other hand, I like zip just fine (though I lament the lack of an 
> >> unzip counterpart).
> > 
> > Eh?  Zip is its own inverse!

> Sure?

> >>> a = [(1,2,3,4),(5,6,7,8)]
> >>> zip(zip(a))
> [(((1, 2, 3, 4),),), (((5, 6, 7, 8),),)]

Paul was surely teasing you, at least a tiny bit.  A few stars are needed:

>>> a = [(1, 2, 3, 4), (5, 6, 7, 8)]
>>> zip(*zip(*a))
[(1, 2, 3, 4), (5, 6, 7, 8)]

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard




More information about the Python-list mailing list