Commit 9a496fb2 authored by Raymond Hettinger's avatar Raymond Hettinger

Tweak column alignment in collections docs.

parent b9b52253
......@@ -174,7 +174,7 @@ For example::
>>> c = Counter() # a new, empty counter
>>> c = Counter('gallahad') # a new counter from an iterable
>>> c = Counter({'red': 4, 'blue': 2}) # a new counter from a mapping
>>> c = Counter(spam=8, eggs=1) # a new counter from keyword args
>>> c = Counter(cats=4, dogs=8) # a new counter from keyword args
Counter objects have a dictionary interface except that they return a zero
count for missing items instead of raising a :exc:`KeyError`::
......@@ -207,10 +207,10 @@ For example::
.. method:: most_common([n])
Return a list of the *n* most common elements and their counts from
the most common to the least. If *n* is not specified or is ``None``,
return a list of all element counts in decreasing order of frequency.
Elements with equal counts are ordered arbitrarily::
Return a list of the *n* most common elements and their counts from the
most common to the least. If *n* not specified, :func:`most_common`
returns *all* elements in the counter. Elements with equal counts are
ordered arbitrarily::
>>> Counter('abracadabra').most_common(3)
[('a', 5), ('r', 2), ('b', 2)]
......@@ -225,16 +225,9 @@ For example::
.. method:: update([iterable-or-mapping])
Elements are counted from an *iterable* or added-in from another
*mapping* (or counter). Like :meth:`dict.update` but adds-in counts
*mapping* (or counter). Like :meth:`dict.update` but adds counts
instead of replacing them. Also, the *iterable* is expected to be a
sequence of elements, not a sequence of ``(key, value)`` pairs::
>>> c = Counter('which')
>>> c.update('witch') # add elements from another iterable
>>> d = Counter('watch')
>>> c.update(d) # add elements from another counter
>>> c['h'] # four 'h' in which, witch, and watch
4
sequence of elements, not a sequence of ``(key, value)`` pairs.
Common patterns for working with :class:`Counter` objects::
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment