mirror of
https://github.com/python/cpython.git
synced 2025-08-21 17:25:34 +00:00
Clean-up named tuple docs.
This commit is contained in:
parent
07750565c9
commit
b6b3879a01
1 changed files with 5 additions and 4 deletions
|
@ -637,7 +637,8 @@ function:
|
||||||
>>> getattr(p, 'x')
|
>>> getattr(p, 'x')
|
||||||
11
|
11
|
||||||
|
|
||||||
To convert a dictionary to a named tuple, use the double-star-operator [#]_:
|
To convert a dictionary to a named tuple, use the double-star-operator
|
||||||
|
(as described in :ref:`tut-unpacking-arguments`):
|
||||||
|
|
||||||
>>> d = {'x': 11, 'y': 22}
|
>>> d = {'x': 11, 'y': 22}
|
||||||
>>> Point(**d)
|
>>> Point(**d)
|
||||||
|
@ -684,7 +685,7 @@ and more efficient to use a simple class declaration:
|
||||||
>>> class Status:
|
>>> class Status:
|
||||||
... open, pending, closed = range(3)
|
... open, pending, closed = range(3)
|
||||||
|
|
||||||
.. rubric:: Footnotes
|
.. seealso::
|
||||||
|
|
||||||
.. [#] For information on the double-star-operator see
|
`Named tuple recipe <http://code.activestate.com/recipes/500261/>`_
|
||||||
:ref:`tut-unpacking-arguments` and :ref:`calls`.
|
adapted for Python 2.4.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue