I have a list of lists like this:
a = d[:3]
>>> a
[[90, 26.7328829998, 131075.449348, 473898.809493],
[90, 78.2985549184, 131116.812991,473929.491012],
[90, 132.4760969, 131157.881628, 473964.821961]]
To change it’s order I use the BIF zip in combination with the *-operator. This get’s me a list of tuples:
>>> b =zip(*a)
>>> b
[(90, 90, 90),
(26.7328829998, 78.2985549184, 132.4760969),
(131075.449348, 131116.812991, 131157.881628),
(473898.809493, 473929.491012, 473964.821961)]
I don’t only want to restore the original order of the items, like:
>>> c = zip(*b)
>>> c
[(90, 26.7328829998, 131075.449348, 473898.809493),
(90, 78.2985549184, 131116.812991, 473929.491012),
(90, 132.4760969, 131157.881628, 473964.821961)]
but also want to get back the original type, e.g. a list of lists. But neither zip(*list(b)) nor list(zip(*b)) do the trick (I wasn’t expecting the second snippet to). Does anyone know how to get there without looping through the list!?
izipreturns a generator so you won’t loop through twice when you createc. In Python 3zip(alsomap,filter, etc.) returns a generator by default andiziphas been removed.