Three dumb questions (ordered by dumbness descending)

Duncan Booth duncan at
Tue Sep 24 05:07:31 EDT 2002

Thorsten Kampe <thorsten at> wrote in news:amnvit$7kqdt$1 at ID-

> 1. Why is 'zip(zip(x)) != x' (should be the same because it's the 
> transposed)

Because zip(x) doesn't transpose x. BUT, zip(*x) does transpose x.
So the question is what zip(*zip(*x)) does?

>>> x = [(1, 2), (3, 4), (5, 6)]
>>> x == zip(*zip(*x))

Provided x is a list of tuples, and you expand the list into separate 
arguments when calling zip, it is indeed its own inverse.

Duncan Booth                                             duncan at
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?

More information about the Python-list mailing list