@@ -853,7 +853,7 @@ they add the ability to access fields by name instead of position index.
853853 Added the *module * parameter.
854854
855855 .. versionchanged :: 3.7
856- Remove the *verbose * parameter and the :attr: `_source ` attribute.
856+ Removed the *verbose * parameter and the :attr: `_source ` attribute.
857857
858858 .. versionchanged :: 3.7
859859 Added the *defaults * parameter and the :attr: `_field_defaults `
@@ -953,14 +953,14 @@ field names, the method and attribute names start with an underscore.
953953 >>> Pixel(11 , 22 , 128 , 255 , 0 )
954954 Pixel(x=11, y=22, red=128, green=255, blue=0)
955955
956- .. attribute :: somenamedtuple._fields_defaults
956+ .. attribute :: somenamedtuple._field_defaults
957957
958958 Dictionary mapping field names to default values.
959959
960960 .. doctest ::
961961
962962 >>> Account = namedtuple(' Account' , [' type' , ' balance' ], defaults = [0 ])
963- >>> Account._fields_defaults
963+ >>> Account._field_defaults
964964 {'balance': 0}
965965 >>> Account(' premium' )
966966 Account(type='premium', balance=0)
@@ -1028,17 +1028,20 @@ customize a prototype instance:
10281028
10291029.. seealso ::
10301030
1031- * `Recipe for named tuple abstract base class with a metaclass mix-in
1032- <https://code.activestate.com/recipes/577629-namedtupleabc-abstract-base-class-mix-in-for-named/> `_
1033- by Jan Kaliszewski. Besides providing an :term: `abstract base class ` for
1034- named tuples, it also supports an alternate :term: `metaclass `-based
1035- constructor that is convenient for use cases where named tuples are being
1036- subclassed.
1031+ * See :class: `typing.NamedTuple ` for a way to add type hints for named
1032+ tuples. It also provides an elegant notation using the :keyword: `class `
1033+ keyword::
1034+
1035+ class Component(NamedTuple):
1036+ part_number: int
1037+ weight: float
1038+ description: Optional[str] = None
10371039
10381040 * See :meth: `types.SimpleNamespace ` for a mutable namespace based on an
10391041 underlying dictionary instead of a tuple.
10401042
1041- * See :meth: `typing.NamedTuple ` for a way to add type hints for named tuples.
1043+ * The :mod: `dataclasses ` module provides a decorator and functions for
1044+ automatically adding generated special methods to user-defined classes.
10421045
10431046
10441047:class: `OrderedDict ` objects
0 commit comments