summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2013-10-06 10:36:39 (GMT)
committerGeorg Brandl <georg@python.org>2013-10-06 10:36:39 (GMT)
commit87f3d7bb54cf2c546bde694b14c5e588fc3e7dbc (patch)
tree3b712793dea47175a9cf3a603ad81f04d62f971c /Doc
parentf27bfd81ecacd7fb2e6fc801a3709fdf3921dd4c (diff)
downloadcpython-87f3d7bb54cf2c546bde694b14c5e588fc3e7dbc.zip
cpython-87f3d7bb54cf2c546bde694b14c5e588fc3e7dbc.tar.gz
cpython-87f3d7bb54cf2c546bde694b14c5e588fc3e7dbc.tar.bz2
Counter: fix recipe for "n least common elements". Found by Mikhail Golubev on docs@.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/collections.rst2
1 files changed, 1 insertions, 1 deletions
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
index a65fe5b..a47d99b 100644
--- a/Doc/library/collections.rst
+++ b/Doc/library/collections.rst
@@ -307,7 +307,7 @@ Common patterns for working with :class:`Counter` objects::
dict(c) # convert to a regular dictionary
c.items() # convert to a list of (elem, cnt) pairs
Counter(dict(list_of_pairs)) # convert from a list of (elem, cnt) pairs
- c.most_common()[:-n:-1] # n least common elements
+ c.most_common()[:-n-1:-1] # n least common elements
+c # remove zero and negative counts
Several mathematical operations are provided for combining :class:`Counter`