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@python components: Documentation messages: 206935 nosy: Julian.Gindi, docs@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 <rep...@bugs.python.org> <http://bugs.python.org/issue20068> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com