This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients Loïc Le Loarer, rhettinger
Date 2017-09-27.21:29:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Except for display the last few elements, this is the documented and intended behavior: ( ):

The returned group is itself an iterator that shares the underlying iterable with groupby(). Because the source is shared, when the groupby() object is advanced, the previous group is no longer visible. So, if that data is needed later, it should be stored as a list:

groups = []
uniquekeys = []
data = sorted(data, key=keyfunc)
for k, g in groupby(data, keyfunc):
    groups.append(list(g))      # Store group iterator as a list

The display of the last few elements isn't supposed to happen.  That is being fixed so that all of the subiterator results are empty when the parent iterator is exhausted.
Date User Action Args
2017-09-27 21:29:33rhettingersetrecipients: + rhettinger, Loïc Le Loarer
2017-09-27 21:29:33rhettingersetmessageid: <>
2017-09-27 21:29:33rhettingerlinkissue31614 messages
2017-09-27 21:29:33rhettingercreate