Jiba added the comment:
Ok, I understand.
However, in my initial problem, the sequence passed to groupby was a set, e.g.
(modifying my previous example) :
groupby(set([p1, p2, p3]), lambda p: p.key)
If I understand well how groupby() works, the result of a groupby performed on
a set
New submission from Jiba :
In some situation, itertools.groupby fails to group the objects, and produces
several groups with the same key. For example, the following code :
from itertools import *
class P(object):
def __init__(self, key):
self.key = key
p1 = P(1)
p2 = P(2)
p3 = P(1