itertools.groupby( ) in python
问题 I have Set of tuples. For example: set([(('E', ('T',)), 0), (('F', ('(', 'E', ')')), 0), (('T', ('F',)), 0), (('__S__', ('E', '$')), 0), (('E', ('E', '+', 'T')), 0), (('T', ('T', '*', 'F')), 0), (('F', ('id',)), 0)]) as you see every tuple has a tuple as it's first element ( ex. ('F', ('(', 'E', ')')) ). first element of this tuple is single character and second element is another tuple ( ex. ('(', 'E', ')')) ). this tuple has one or more single character in it. (It is actually Context Free