[issue1696199] Add collections.counts()
Steven Bethard
report at bugs.python.org
Mon Jan 12 19:55:10 CET 2009
Steven Bethard <steven.bethard at gmail.com> added the comment:
The whole point was to have a function (or class) that accumulates a
sequence and counts it. collections.defaultdict(lambda: 0) doesn't
achieve this on its own because it only knows how to handle sequences of
(key, value):
>>> d = collections.defaultdict(lambda: 0)
>>> d.update('aaabbac')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: dictionary update sequence element #0 has length 1; 2 is
required
The feature request here was mainly a request to provide an abbreviation
of a very common 4-line function.
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1696199>
_______________________________________
More information about the Python-bugs-list
mailing list