How to reverse tuples in a list?

Boris Borcic bborcic at gmail.com
Wed Aug 9 09:26:12 EDT 2006


Applying the perl motto (there is more than one way to do it) sure enough leads 
to a perlish solution... as measured by line noise.

 >>> t = [('a', 11,1.0), ('b',22,2.0),('c',33,3.0)]
 >>> zip(*zip(*t)[::-1])
[(1.0, 11, 'a'), (2.0, 22, 'b'), (3.0, 33, 'c')]




More information about the Python-list mailing list