This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Julian.Gindi
Recipients Julian.Gindi, docs@python, rhettinger
Date 2013-12-26.06:42:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1388040167.94.0.902280065341.issue20068@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-12-26 06:42:48Julian.Gindisetrecipients: + Julian.Gindi, rhettinger, docs@python
2013-12-26 06:42:47Julian.Gindisetmessageid: <1388040167.94.0.902280065341.issue20068@psf.upfronthosting.co.za>
2013-12-26 06:42:47Julian.Gindilinkissue20068 messages
2013-12-26 06:42:46Julian.Gindicreate