Commit a54d287d authored by Raymond Hettinger's avatar Raymond Hettinger

Issue 6722: Improve the namedtuple examples.

parent 945d5a8a
...@@ -586,11 +586,15 @@ they add the ability to access fields by name instead of position index. ...@@ -586,11 +586,15 @@ they add the ability to access fields by name instead of position index.
.. versionchanged:: 3.1 .. versionchanged:: 3.1
Added support for *rename*. Added support for *rename*.
Example:
.. doctest:: .. doctest::
:options: +NORMALIZE_WHITESPACE :options: +NORMALIZE_WHITESPACE
>>> # Basic example
>>> Point = namedtuple('Point', 'x y')
>>> p = Point(x=10, y=11)
>>> # Example using the verbose option to print the class definition
>>> Point = namedtuple('Point', 'x y', verbose=True) >>> Point = namedtuple('Point', 'x y', verbose=True)
class Point(tuple): class Point(tuple):
'Point(x, y)' 'Point(x, y)'
......
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