opposite of zip()?
Rich Harkins
rich at worldsinfinite.com
Mon Dec 17 14:26:14 EST 2007
Matt Nordhoff wrote:
[snip]
>
> As Paddy wrote, zip is its own unzip:
>
>>>> zipped = zip((1, 2, 3), (4, 5, 6))
>>>> zipped
> [(1, 4), (2, 5), (3, 6)]
>>>> unzipped = zip(*zipped)
>>>> unzipped
> [(1, 2, 3), (4, 5, 6)]
>
> Neat and completely confusing, huh? :-)
>
> <http://paddy3118.blogspot.com/2007/02/unzip-un-needed-in-python.html>
I hadn't thought about zip() being symmetrical like that. Very cool...
Rich
More information about the Python-list
mailing list