inverse of the zip function

Simon Burton simonb at webone.com.au
Tue Jul 29 18:31:47 EDT 2003


On Tue, 29 Jul 2003 22:06:20 +0000, Raymond Hettinger wrote:

> "David C. Fox" <davidcfox at post.harvard.edu> wrote in message
> news:9sBVa.12998$o%2.6289 at sccrnsc02...
>> Is there a function which takes a list of tuples and returns a list of
>> lists made up of the first element of each tuple, the second element of
>> each tuple, etc.?
>>
>> In other words, the the inverse of the built-in zip function?
> 
> When used with the * operator, zip() is its own inverse:
> 

This (obviously) doesn't work when z has length 0 or 2.
I don't quite understand why zip is overloaded ...

Oh, hang on, it does work for length 2! that's neat-o,
and perhaps that's why zip was extended. Is it a functional programming
convention, i wonder.

Simon.





More information about the Python-list mailing list