Moshe Zadka wrote:
(assume a = [1, 2, 3])
On Mon, 17 Jul 2000, Gordon McMillan wrote:
How about a fourth: zip(a) is the same as zip(a, []) ?
Huh???????????????????
I think he meant: zip((a,[]))
Look at it this way: what should zip(a, pad=None) return?
[(1,), (2,), (3,)], of course
Obviously: [(1, None), (2, None), (3, None)]
Why?
Good question ;-) Here's another one: why should zip() have this special case at all ? I mean, have you ever seen a zipper with only one part ? Ok, there is one-hand clapping, but I wouldn't consider this the normal mode of operation ;-) IMHO, all the special casing does is mask programming errors. And another one: zip() as defined is an operation which is -- in some respects -- the inverse of itself, yet the name does not carry this information. You can't zip a zipper twice. The mathematical operation behind it is called transposition (you view the sequence of sequences as matrix), so in that light the natural name would be transpose()... tranpose(transpose(matrix))) has the same structure as matrix itself. -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/