Message206935
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. |
|
Date |
User |
Action |
Args |
2013-12-26 06:42:48 | Julian.Gindi | set | recipients:
+ Julian.Gindi, rhettinger, docs@python |
2013-12-26 06:42:47 | Julian.Gindi | set | messageid: <1388040167.94.0.902280065341.issue20068@psf.upfronthosting.co.za> |
2013-12-26 06:42:47 | Julian.Gindi | link | issue20068 messages |
2013-12-26 06:42:46 | Julian.Gindi | create | |
|