split up a list by condition?

gene tani gene.tani at gmail.com
Tue Jun 7 01:20:17 EDT 2005


Sounds like itertools.groupby() is what you're looking for, just sort
your sequence on the grouping func that you will pass as 2nd arg to
groupby(), before you pass the sequence to groupby()

http://www.python.org/doc/2.4/whatsnew/node13.html
http://www.python.org/dev/doc/devel/lib/itertools-functions.html




More information about the Python-list mailing list