July 3, 2018
10:44 p.m.
Steven D'Aprano wrote:
I propose that a better name which indicates the non-lazy nature of this function is *grouped* rather than grouping, like sorted().
+1
As for where it belongs, perhaps the collections module is the least worst fit.
But then there's the equally strong purist argument that it's not a data type, just a function. Unless we *make* it a data type. Then not only would it fit well in collections, it would also make it fairly easy to do incremental grouping if you really wanted that. Usual case: g = groupdict((key(val), val) for val in things) Incremental case: g = groupdict() for key(val), val in things: g.add(key, val) process_partial_grouping(g) -- Greg