itertools.groupby enables you to do this, you just need to define a suitable grouping function, that stores its state:
Michael, this would make a great Python Cookbook Recipe.
--Scott David Daniels [EMAIL PROTECTED]
-- http://mail.python.org/mailman/listinfo/python-list