Unpacking operation:
In [1]: data = [(1,2),(40,2),(9,80)] In [2]: zip(*data) Out[2]: [(1, 40, 9), (2, 2, 80)]
Edit: you can decompose the resulting list when assigning:
In [3]: first_elements, second_elements = zip(*data)
And if you really need lists as results:
In [4]: first_elements, second_elements = map(list, zip(*data))
To better understand why this works:
zip(*data)
equivalently
zip((1,2), (40,2), (9,80))
Two tuples in the list of results are constructed from the first elements of the zip () arguments and from the second elements of the zip () arguments.
unbeknown
source share