[docs] [issue20068] collections.Counter documentation leaves out interesting usecase
Julian Gindi
report at bugs.python.org
Thu Dec 26 07:42:48 CET 2013
New submission from Julian Gindi:
I think the documentation for collections.Counter can be updated slightly to include an example showing the initialization of a counter object from a list. For example, it explains how to manually iterate through a list and increment the values...
for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']:
... cnt[word] += 1
I think it is more useful and powerful to do something like this:
cnt = Counter(['red', 'blue', 'red', 'green', 'blue', 'blue'])
where the result would be:
Counter({'blue': 3, 'red': 2, 'green': 1})
Just a thought. I'm curious to see what other people think.
----------
assignee: docs at python
components: Documentation
messages: 206935
nosy: Julian.Gindi, docs at python, rhettinger
priority: normal
severity: normal
status: open
title: collections.Counter documentation leaves out interesting usecase
type: enhancement
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20068>
_______________________________________
More information about the docs
mailing list