[New-bugs-announce] [issue16994] collections.Counter.least_common

David Coallier report at bugs.python.org
Fri Jan 18 13:24:33 CET 2013

New submission from David Coallier:

The `collections.Counter` library contains very useful methods for playing with dicts and sets (mainly the most_common()) function.

Even though it is fairly trivial to retrieve the least common elements in a Counter() by doing Counter(...).most_common(n)[:-n:-1] I believe that for the sake of consistency, the `least_common` method should also be available. 

The attached patch contains the following:
- The method definition in Lib/__init__.py to support least_common;
- The tests to make sure least_common behaves as expected;
- The documentation for 2.7 and the general documentation.

Everywhere `most_common` was mentioned, you will now find `least_common` mentioned as well.

components: Library (Lib)
files: collections.Counter.least_common.patch
keywords: patch
messages: 180189
nosy: davidcoallier
priority: normal
severity: normal
status: open
title: collections.Counter.least_common
type: enhancement
versions: Python 2.7
Added file: http://bugs.python.org/file28764/collections.Counter.least_common.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list