[docs] [issue28939] Groupby Is Roughly Equivalent To ...

Julien Palard report at bugs.python.org
Sun Dec 11 15:54:02 EST 2016


Julien Palard added the comment:

I renamed your function groupby2 to compare it with itertools.groupby and tested but:

>>> print(list(groupby2(['A', 'B'])))

does not returns, looks like your implementation have a bug, so I tried:

>>> for k in groupby2(['A', 'B']):
...     print(k)

and I'm getting loads of:

('A', <generator object groupby2._group at 0x7f0476809f10>)
('A', <generator object groupby2._group at 0x7f0476851f68>)
('A', <generator object groupby2._group at 0x7f0476809f10>)
('A', <generator object groupby2._group at 0x7f0476851f68>)
('A', <generator object groupby2._group at 0x7f0476809f10>)
('A', <generator object groupby2._group at 0x7f0476851f68>)
('A', <generator object groupby2._group at 0x7f0476809f10>)
('A', <generator object groupby2._group at 0x7f0476851f68>)
('A', <generator object groupby2._group at 0x7f0476809f10>)
('A', <generator object groupby2._group at 0x7f0476851f68>)

You may also want to test your implementation against https://github.com/python/cpython/blob/master/Lib/test/test_itertools.py#L699

----------
nosy: +mdk

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28939>
_______________________________________


More information about the docs mailing list