Message403031
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. |
|
Date |
User |
Action |
Args |
2021-10-01 20:26:02 | Dennis Sweeney | set | recipients:
+ Dennis Sweeney, rhettinger, kubataytekin |
2021-10-01 20:26:02 | Dennis Sweeney | set | messageid: <1633119962.78.0.804677864935.issue45338@roundup.psfhosted.org> |
2021-10-01 20:26:02 | Dennis Sweeney | link | issue45338 messages |
2021-10-01 20:26:02 | Dennis Sweeney | create | |
|