Dennis Sweeney <[email protected]> added the comment:
The values of a Counter are generally integers, not lists. Maybe you want:
items_by_keyfunc = defaultdict(list)
for x in all_the_items:
items_by_keyfunc[keyfunc(x)].append(x)
Then items_by_keyfunc[42] is a list of the things with key 42.
Although I believe there have been proposals about adding some method to dict()
to do basically the for-loop above.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue45338>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com