import itertools
import operator
data = [(1, 'A', 'foo'), (2, 'A', 'bar'), (100, 'A', 'foo-bar'), ('xx', 'B',
    'foobar'), ('yy', 'B', 'foo'), (1000, 'C', 'py'), (200, 'C', 'foo')]
for key, group in itertools.groupby(data, operator.itemgetter(1)):
    pass
Split a list of tuples into sub-lists of the same tuple field