Clarify how to add a field to a named tuple.
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
index b276ab0..1e213fb 100644
--- a/Doc/library/collections.rst
+++ b/Doc/library/collections.rst
@@ -538,7 +538,7 @@
Subclassing is not useful for adding new, stored fields. Instead, simply
create a new named tuple type from the :attr:`_fields` attribute::
- >>> Pixel = namedtuple('Pixel', Point._fields + Color._fields)
+ >>> Point3D = namedtuple('Point3D', Point._fields + ('z',))
Default values can be implemented by using :meth:`_replace` to
customize a prototype instance::
diff --git a/Lib/collections.py b/Lib/collections.py
index 47b0397..267c39f 100644
--- a/Lib/collections.py
+++ b/Lib/collections.py
@@ -137,6 +137,9 @@
print Point(11, 22)._replace(x=100)
+ Point3D = namedtuple('Point3D', Point._fields + ('z',))
+ print Point3D.__doc__
+
import doctest
TestResults = namedtuple('TestResults', 'failed attempted')
print TestResults(*doctest.testmod())