[Python-checkins] cpython (2.7): Counter: fix recipe for "n least common elements". Found by Mikhail Golubev on

georg.brandl python-checkins at python.org
Sun Oct 6 12:36:36 CEST 2013


http://hg.python.org/cpython/rev/7add9ea59507
changeset:   86056:7add9ea59507
branch:      2.7
user:        Georg Brandl <georg at python.org>
date:        Sun Oct 06 12:36:39 2013 +0200
summary:
  Counter: fix recipe for "n least common elements". Found by Mikhail Golubev on docs at .

files:
  Doc/library/collections.rst |  2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
--- a/Doc/library/collections.rst
+++ b/Doc/library/collections.rst
@@ -146,7 +146,7 @@
     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 += Counter()                  # remove zero and negative counts
 
 Several mathematical operations are provided for combining :class:`Counter`

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list