mirror of https://github.com/python/cpython
Update the seealso entries for namedtuple() (GH-12373)
* Replace external recipe link with a link to the dataclasses module. * Highlight the class definition syntax for typing.NamedTuple and add an example for clarity.
This commit is contained in:
parent
5927cfdf3a
commit
9c68543f02
|
@ -1028,17 +1028,20 @@ customize a prototype instance:
|
||||||
|
|
||||||
.. seealso::
|
.. seealso::
|
||||||
|
|
||||||
* `Recipe for named tuple abstract base class with a metaclass mix-in
|
* See :class:`typing.NamedTuple` for a way to add type hints for named
|
||||||
<https://code.activestate.com/recipes/577629-namedtupleabc-abstract-base-class-mix-in-for-named/>`_
|
tuples. It also provides an elegant notation using the :keyword:`class`
|
||||||
by Jan Kaliszewski. Besides providing an :term:`abstract base class` for
|
keyword::
|
||||||
named tuples, it also supports an alternate :term:`metaclass`-based
|
|
||||||
constructor that is convenient for use cases where named tuples are being
|
class Component(NamedTuple):
|
||||||
subclassed.
|
part_number: int
|
||||||
|
weight: float
|
||||||
|
description: Optional[str] = None
|
||||||
|
|
||||||
* See :meth:`types.SimpleNamespace` for a mutable namespace based on an
|
* See :meth:`types.SimpleNamespace` for a mutable namespace based on an
|
||||||
underlying dictionary instead of a tuple.
|
underlying dictionary instead of a tuple.
|
||||||
|
|
||||||
* See :meth:`typing.NamedTuple` for a way to add type hints for named tuples.
|
* The :mod:`dataclasses` module provides a decorator and functions for
|
||||||
|
automatically adding generated special methods to user-defined classes.
|
||||||
|
|
||||||
|
|
||||||
:class:`OrderedDict` objects
|
:class:`OrderedDict` objects
|
||||||
|
|
|
@ -815,7 +815,7 @@ The module defines the following classes, functions and decorators:
|
||||||
|
|
||||||
.. class:: NamedTuple
|
.. class:: NamedTuple
|
||||||
|
|
||||||
Typed version of namedtuple.
|
Typed version of :func:`collections.namedtuple`.
|
||||||
|
|
||||||
Usage::
|
Usage::
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue