[issue45338] Add key argument to collections.Counter

kubat aytekin report at bugs.python.org
Fri Oct 1 04:19:49 EDT 2021


New submission from kubat aytekin <kubataytekin at yahoo.com.tr>:

Counter has become the default tool for counting occurences of objects in an iterable. However by construction it only works on hashable objects as it is a subclass of dict. Would it be possible to implement a "key=" keyword argument as in sort etc.? 

Here's a stackoverflow question wherein either map or implementing a hash method was proposed:
https://stackoverflow.com/questions/69401713/elegant-way-of-counting-items-in-a-list-by-enum-value-in-python

----------
components: Library (Lib)
messages: 403002
nosy: kubataytekin
priority: normal
severity: normal
status: open
title: Add key argument to collections.Counter
type: enhancement
versions: Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45338>
_______________________________________


More information about the Python-bugs-list mailing list