Steven Bethard wrote:
Diez B. Roggisch wrote:
zip(*[(1,4),(2,5),(3,6)])
While this is also the approach I would use, it is worth noting that Guido thinks of this as an abuse of the argument passing machinery:
http://mail.python.org/pipermail/python-dev/2003-July/037346.html
I'm not sure that's the same thread I already read where he dissed zip like that, but what I'm wondering is what is the alternative? Is there an equally elegant approach that doesn't "abuse" the argument passing machinery?
I know I found it in another thread before. I think he's said it a few times.
Personally, I wish that, if we're not to use zip like this, that Python would provide a builtin 'unzip' to do the corresponding thing.
If you're interested in a recipe that does this, you can look at my 'starzip' recipe which is basically 'unzip' for iterators:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/302325
I guess if we wanted a standard solution to the 'unzip' problem, I could rally for this to be added to itertools, but I'm not sure I'm up to the task of rewriting it in C...
Steve -- http://mail.python.org/mailman/listinfo/python-list