[docs] Typo in collections.Counter class example

Михаил Голубев qsolo825 at gmail.com
Wed Jun 5 19:16:18 CEST 2013


It seems that I found micro bug in Python documentation describing
There is the following snippet of code

c.most_common()[:-n:-1]         # n least common elements

Actually this expression returns not *n* least common elements, but rather *n
- 1,* beacuse second boundary  is not included (as usual with slices).
You probably meant c.most_common()[-n:] or c.most_common()[:-n-1:-1] if
reverse ordering is nesessary.

Best regards
Mikhail Golubev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20130605/c4c9d8e3/attachment-0001.html>

More information about the docs mailing list