@@ -114,7 +114,7 @@ The class can be used to simulate nested scopes and is useful in templating.
114114 for templating is a read-only chain of mappings. It also features
115115 pushing and popping of contexts similar to the
116116 :meth: `~collections.ChainMap.new_child ` method and the
117- :meth : `~collections.ChainMap.parents ` property.
117+ :attr : `~collections.ChainMap.parents ` property.
118118
119119 * The `Nested Contexts recipe
120120 <https://code.activestate.com/recipes/577434/> `_ has options to control
@@ -270,7 +270,7 @@ For example::
270270
271271 Return a list of the *n * most common elements and their counts from the
272272 most common to the least. If *n * is omitted or ``None ``,
273- :func : `most_common ` returns *all * elements in the counter.
273+ :meth : `most_common ` returns *all * elements in the counter.
274274 Elements with equal counts are ordered arbitrarily:
275275
276276 >>> Counter(' abracadabra' ).most_common(3 ) # doctest: +SKIP
@@ -357,20 +357,20 @@ or subtracting from an empty counter.
357357 restrictions on its keys and values. The values are intended to be numbers
358358 representing counts, but you *could * store anything in the value field.
359359
360- * The :meth: `most_common ` method requires only that the values be orderable.
360+ * The :meth: `~Counter. most_common ` method requires only that the values be orderable.
361361
362362 * For in-place operations such as ``c[key] += 1 ``, the value type need only
363363 support addition and subtraction. So fractions, floats, and decimals would
364364 work and negative values are supported. The same is also true for
365- :meth: `update ` and :meth: `subtract ` which allow negative and zero values
365+ :meth: `~Counter. update ` and :meth: `~Counter. subtract ` which allow negative and zero values
366366 for both inputs and outputs.
367367
368368 * The multiset methods are designed only for use cases with positive values.
369369 The inputs may be negative or zero, but only outputs with positive values
370370 are created. There are no type restrictions, but the value type needs to
371371 support addition, subtraction, and comparison.
372372
373- * The :meth: `elements ` method requires integer counts. It ignores zero and
373+ * The :meth: `~Counter. elements ` method requires integer counts. It ignores zero and
374374 negative counts.
375375
376376.. seealso ::
@@ -388,9 +388,9 @@ or subtracting from an empty counter.
388388 Section 4.6.3, Exercise 19 *.
389389
390390 * To enumerate all distinct multisets of a given size over a given set of
391- elements, see :func: `itertools.combinations_with_replacement `:
391+ elements, see :func: `itertools.combinations_with_replacement `::
392392
393- map(Counter, combinations_with_replacement('ABC', 2)) --> AA AB AC BB BC CC
393+ map(Counter, combinations_with_replacement('ABC', 2)) # --> AA AB AC BB BC CC
394394
395395
396396:class: `deque ` objects
@@ -640,18 +640,18 @@ the :meth:`~deque.rotate` method::
640640 # Remove an exhausted iterator.
641641 iterators.popleft()
642642
643- The :meth: `rotate ` method provides a way to implement :class: `deque ` slicing and
643+ The :meth: `~deque. rotate ` method provides a way to implement :class: `deque ` slicing and
644644deletion. For example, a pure Python implementation of ``del d[n] `` relies on
645- the :meth: ` rotate ` method to position elements to be popped::
645+ the `` rotate() ` ` method to position elements to be popped::
646646
647647 def delete_nth(d, n):
648648 d.rotate(-n)
649649 d.popleft()
650650 d.rotate(n)
651651
652652To implement :class: `deque ` slicing, use a similar approach applying
653- :meth: `rotate ` to bring a target element to the left side of the deque. Remove
654- old entries with :meth: `popleft `, add new entries with :meth: `extend `, and then
653+ :meth: `~deque. rotate ` to bring a target element to the left side of the deque. Remove
654+ old entries with :meth: `~deque. popleft `, add new entries with :meth: `~deque. extend `, and then
655655reverse the rotation.
656656With minor variations on that approach, it is easy to implement Forth style
657657stack manipulations such as ``dup ``, ``drop ``, ``swap ``, ``over ``, ``pick ``,
@@ -712,7 +712,7 @@ stack manipulations such as ``dup``, ``drop``, ``swap``, ``over``, ``pick``,
712712:class: `defaultdict ` Examples
713713^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
714714
715- Using :class: `list ` as the :attr: `default_factory `, it is easy to group a
715+ Using :class: `list ` as the :attr: `~defaultdict. default_factory `, it is easy to group a
716716sequence of key-value pairs into a dictionary of lists:
717717
718718 >>> s = [(' yellow' , 1 ), (' blue' , 2 ), (' yellow' , 3 ), (' blue' , 4 ), (' red' , 1 )]
@@ -724,7 +724,7 @@ sequence of key-value pairs into a dictionary of lists:
724724 [('blue', [2, 4]), ('red', [1]), ('yellow', [1, 3])]
725725
726726When each key is encountered for the first time, it is not already in the
727- mapping; so an entry is automatically created using the :attr: `default_factory `
727+ mapping; so an entry is automatically created using the :attr: `~defaultdict. default_factory `
728728function which returns an empty :class: `list `. The :meth: `list.append `
729729operation then attaches the value to the new list. When keys are encountered
730730again, the look-up proceeds normally (returning the list for that key) and the
@@ -738,7 +738,7 @@ simpler and faster than an equivalent technique using :meth:`dict.setdefault`:
738738 >>> sorted (d.items())
739739 [('blue', [2, 4]), ('red', [1]), ('yellow', [1, 3])]
740740
741- Setting the :attr: `default_factory ` to :class: `int ` makes the
741+ Setting the :attr: `~defaultdict. default_factory ` to :class: `int ` makes the
742742:class: `defaultdict ` useful for counting (like a bag or multiset in other
743743languages):
744744
@@ -751,7 +751,7 @@ languages):
751751 [('i', 4), ('m', 1), ('p', 2), ('s', 4)]
752752
753753When a letter is first encountered, it is missing from the mapping, so the
754- :attr: `default_factory ` function calls :func: `int ` to supply a default count of
754+ :attr: `~defaultdict. default_factory ` function calls :func: `int ` to supply a default count of
755755zero. The increment operation then builds up the count for each letter.
756756
757757The function :func: `int ` which always returns zero is just a special case of
@@ -766,7 +766,7 @@ zero):
766766 >>> ' %(name)s %(action)s to %(object)s ' % d
767767 'John ran to <missing>'
768768
769- Setting the :attr: `default_factory ` to :class: `set ` makes the
769+ Setting the :attr: `~defaultdict. default_factory ` to :class: `set ` makes the
770770:class: `defaultdict ` useful for building a dictionary of sets:
771771
772772 >>> s = [(' red' , 1 ), (' blue' , 2 ), (' red' , 3 ), (' blue' , 4 ), (' red' , 1 ), (' blue' , 4 )]
@@ -973,7 +973,7 @@ The subclass shown above sets ``__slots__`` to an empty tuple. This helps
973973keep memory requirements low by preventing the creation of instance dictionaries.
974974
975975Subclassing is not useful for adding new, stored fields. Instead, simply
976- create a new named tuple type from the :attr: `_fields ` attribute:
976+ create a new named tuple type from the :attr: `~somenamedtuple. _fields ` attribute:
977977
978978 >>> Point3D = namedtuple(' Point3D' , Point._fields + (' z' ,))
979979
@@ -989,7 +989,7 @@ fields:
989989.. versionchanged :: 3.5
990990 Property docstrings became writeable.
991991
992- Default values can be implemented by using :meth: `_replace ` to
992+ Default values can be implemented by using :meth: `~somenamedtuple. _replace ` to
993993customize a prototype instance:
994994
995995 >>> Account = namedtuple(' Account' , ' owner balance transaction_count' )
@@ -1200,15 +1200,22 @@ subclass directly from :class:`str`; however, this class can be easier
12001200to work with because the underlying string is accessible as an
12011201attribute.
12021202
1203- .. class :: UserString([sequence] )
1203+ .. class :: UserString(seq )
12041204
1205- Class that simulates a string or a Unicode string object. The instance's
1205+ Class that simulates a string object. The instance's
12061206 content is kept in a regular string object, which is accessible via the
12071207 :attr: `data ` attribute of :class: `UserString ` instances. The instance's
1208- contents are initially set to a copy of *sequence *. The *sequence * can
1209- be an instance of :class: `bytes `, :class: `str `, :class: `UserString ` (or a
1210- subclass) or an arbitrary sequence which can be converted into a string using
1211- the built-in :func: `str ` function.
1208+ contents are initially set to a copy of *seq *. The *seq * argument can
1209+ be any object which can be converted into a string using the built-in
1210+ :func: `str ` function.
1211+
1212+ In addition to supporting the methods and operations of strings,
1213+ :class: `UserString ` instances provide the following attribute:
1214+
1215+ .. attribute :: data
1216+
1217+ A real :class: `str ` object used to store the contents of the
1218+ :class: `UserString ` class.
12121219
12131220 .. versionchanged :: 3.5
12141221 New methods ``__getnewargs__ ``, ``__rmod__ ``, ``casefold ``,
0 commit comments