[Python-checkins] r58216 - python/trunk/Doc/library/collections.rst
raymond.hettinger
python-checkins at python.org
Thu Sep 20 05:03:43 CEST 2007
Author: raymond.hettinger
Date: Thu Sep 20 05:03:43 2007
New Revision: 58216
Modified:
python/trunk/Doc/library/collections.rst
Log:
Fit nits
Modified: python/trunk/Doc/library/collections.rst
==============================================================================
--- python/trunk/Doc/library/collections.rst (original)
+++ python/trunk/Doc/library/collections.rst Thu Sep 20 05:03:43 2007
@@ -360,8 +360,8 @@
.. _named-tuple-factory:
-:func:`NamedTuple` factory function
------------------------------------
+:func:`NamedTuple` Factory Function for Tuples with Named Fields
+----------------------------------------------------------------
Named tuples assign meaning to each position in a tuple and allow for more readable,
self-documenting code. They can be used wherever regular tuples are used, and
@@ -376,12 +376,12 @@
method which lists the tuple contents in a ``name=value`` format.
The *fieldnames* are specified in a single string with each fieldname separated by
- a space and/or comma. Any valid Python identifier may be used for a field name.
+ a space and/or comma. Any valid Python identifier may be used for a fieldname.
- If *verbose* is true, the *NamedTuple* call will print the class definition.
+ If *verbose* is true, will print the class definition.
*NamedTuple* instances do not have per-instance dictionaries, so they are
- lightweight, requiring no more memory than regular tuples.
+ lightweight and require no more memory than regular tuples.
.. versionadded:: 2.6
@@ -434,7 +434,9 @@
.. method:: somenamedtuple.replace(field, value)
- Return a new instance of the named tuple replacing the named *field* with a new *value*::
+ Return a new instance of the named tuple replacing the named *field* with a new *value*:
+
+::
>>> p = Point(x=11, y=22)
>>> p.__replace__('x', 33)
@@ -447,7 +449,9 @@
Return a tuple of strings listing the field names. This is useful for introspection,
for converting a named tuple instance to a dictionary, and for combining named tuple
- types to create new named tuple types::
+ types to create new named tuple types:
+
+::
>>> p.__fields__ # view the field names
('x', 'y')
More information about the Python-checkins
mailing list