zip() is simple and tricky buit-in python function at the same time.
>>> zip(range(3), '123')
... [(0, '1'), (1, '2'), (2, '3')]
That's simple, heh. :)
The trickest part is when you've got the result of your zip(a, b), but you want to unzip it.
>>> a1 = (1, 2, 3)
>>> b1 = (4, 5, 6)
>>> c = zip(a1, c1)
>>> # woo-a la
>>> a2, b2 = zip(*c)
>>> print a1 == a2 and b1 == b2
... True
We've got the origial values. Congrats!
BTW, unzip is described in python documentation http://docs.python.org/library/functions.html#zip
>>> zip(range(3), '123')
... [(0, '1'), (1, '2'), (2, '3')]
That's simple, heh. :)
The trickest part is when you've got the result of your zip(a, b), but you want to unzip it.
>>> a1 = (1, 2, 3)
>>> b1 = (4, 5, 6)
>>> c = zip(a1, c1)
>>> # woo-a la
>>> a2, b2 = zip(*c)
>>> print a1 == a2 and b1 == b2
... True
We've got the origial values. Congrats!
BTW, unzip is described in python documentation http://docs.python.org/library/functions.html#zip