[Python-Dev] PEP 201 - Parallel iteration
Gordon McMillan
gmcm@hypernet.com
Tue, 18 Jul 2000 15:11:37 -0400
Moshe wrote:
> I disagree: you agree that if you add a pad argument when the
> lists are all the same size it doesn't matter (if you don't agree
> with this, you don't agree with the PEP). Now, when there is only
> one list, the lists are all the same size. QED.
I would agree if we were talking about transpose(matrix,
[pad]). Then:
transpose([(1,2,3)]) -> [(1,), (2,), (3,)] and
transpose([(1,), (2,), (3,)]) -> [(1,2,3)]
That is, a 3X1 transposes to a 1X3 and vice versa.
But zip doesn't take a matrix, it takes some number of
sequences.
Oh heck, I'll agree anyway. But I dread explaining why
1) it doesn't behave like map(None, [1,2,3])
2) why zip(((1,2),(3,4))) doesn't yield [(1,3), (2,4)] but [((1,2),),
((3,4),)] instead!
So: document zip as taking 2 or more sequences, and throw
an exception if fed only one.
- Gordon