Raymond Hettinger <raymond.hettin...@gmail.com> added the comment: Except for display the last few elements, this is the documented and intended behavior: ( https://docs.python.org/3/library/itertools.html#itertools.groupby ):
''' 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 uniquekeys.append(k) ''' 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. ---------- assignee: -> rhettinger nosy: +rhettinger resolution: -> not a bug stage: -> resolved status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue31614> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com