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

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


http://hg.python.org/cpython/rev/b7941783b6cc
changeset:   86057:b7941783b6cc
branch:      3.3
parent:      86053:a2df78cba708
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
@@ -307,7 +307,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                              # 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