From: Raymond Hettinger Date: Sun, 21 Nov 2010 23:23:29 +0000 (+0000) Subject: Issue 6722: Improve the namedtuple examples. X-Git-Tag: v3.2b1~254 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0ef956f9974c649bfc64550f8597cec13cfe21f8;p=thirdparty%2FPython%2Fcpython.git Issue 6722: Improve the namedtuple examples. --- diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst index e34e39479b05..3f81c00c20dc 100644 --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -586,11 +586,15 @@ they add the ability to access fields by name instead of position index. .. versionchanged:: 3.1 Added support for *rename*. -Example: .. doctest:: :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) class Point(tuple): 'Point(x, y)'