diff options
author | Raymond Hettinger <python@rcn.com> | 2009-02-25 22:48:24 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2009-02-25 22:48:24 (GMT) |
commit | a665853bab7ac309f224fa1e9b96d81aa9227838 (patch) | |
tree | fc8b14b819c9f015392dd2db70c22915eb0ce861 | |
parent | e3bc0eff256e5eda47a4190171db65ad5b9102db (diff) | |
download | cpython-a665853bab7ac309f224fa1e9b96d81aa9227838.zip cpython-a665853bab7ac309f224fa1e9b96d81aa9227838.tar.gz cpython-a665853bab7ac309f224fa1e9b96d81aa9227838.tar.bz2 |
Clarify Counter() docs.
-rw-r--r-- | Doc/library/collections.rst | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst index 2f7785e..d6d7ebb 100644 --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -251,14 +251,12 @@ Common patterns for working with :class:`Counter` objects:: c.most_common()[:-n:-1] # n least common elements c += Counter() # remove zero and negative counts -Several multiset mathematical operations are provided for combining -:class:`Counter` objects. Multisets are counters with the restriction -that all counts are at least one. They are like regular sets but are -allowed to contain repeated elements. Addition and subtraction combine -counters by adding or subtracting the counts of corresponding elements. -Intersection and union return the minimum and maximum of corresponding -counts. Each operation can accept inputs with signed counts, -but the output excludes results with counts less than one. +Several mathematical operations are provided for combining :class:`Counter` +objects to produce multisets (counters that have counts greater than zero). +Addition and subtraction combine counters by adding or subtracting the counts +of corresponding elements. Intersection and union return the minimum and +maximum of corresponding counts. Each operation can accept inputs with signed +counts, but the output will exclude results with counts of zero or less. >>> c = Counter(a=3, b=1) >>> d = Counter(a=1, b=2) |