[Python-Dev] PEP 201 - Parallel iteration

Peter Schneider-Kamp peter@schneider-kamp.de
Tue, 18 Jul 2000 11:23:38 +0000


Ken Manheimer wrote:
> 
> Evan Simpson (a colleague here at digicool, who'd be a good addition
> to python-dev) noticed that unzip is unnecessary - zip is its own
> inverse.  Since this is a worthwhile observation, i'll indulge a bit
> and present it in evan's terms - particularly noting a different
> packaging that i think is pretty cool, as methods on sequences.

Yeah, but this is only true if we let zip() be a sequence
method (or a function taking a sequence):

for x,y in [[1, 2, 3], [4, 5, 6]].zip():

for x,y in zip([[1, 2, 3], [4, 5, 6]]):

for x,y in zip([1, 2, 3], [4, 5, 6]):

To be fair I'll do second one:

a = [1, 2, 3]
b = [4, 5, 6]
c = [7, 8, 9]

for x,y,z in [a, b, c].zip():

for x,y,z in zip([a, b, c]):

for x,y,z in zip(a, b, c):

I still think the third form is more explicit, but I am
+0 on making zip() a sequence method.

Peter
--
Peter Schneider-Kamp          ++47-7388-7331
Herman Krags veg 51-11        mailto:peter@schneider-kamp.de
N-7050 Trondheim              http://schneider-kamp.de