[Python Wpg] Sort a list of tuples!

Stuart Williams stuartw at mts.net
Mon Apr 24 22:04:12 EDT 2006


>> This reminds me of a related question, is there a nice pythonish
>> way to iterate through too equally sized lists in parallel?

> If the lists are the exact same size, the builtin function zip() is
> probably what you are looking for...

There's also itertools.zip (and a bunch of friends) which handles long
lists like the two_iter_generator function Mark gave, building only as
necessary instead of up front.  This is also very useful for zipping
lists where one or more of the sequences being zipped isn't a list at
all but an iterator, for example reading a large file.

Stuart.



More information about the Winnipeg mailing list