summaryrefslogtreecommitdiffstats
path: root/Doc/glossary.rst
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2008-01-13 06:15:15 (GMT)
committerRaymond Hettinger <python@rcn.com>2008-01-13 06:15:15 (GMT)
commitc20ed51dc38b77cfcd169ab4aed3cb2b5aa9d961 (patch)
tree83a2ebb1c49d728f460528496292ff9bbe44db98 /Doc/glossary.rst
parentfca4e1ffa19234a8c95828d8c106080ef184a1dd (diff)
downloadcpython-c20ed51dc38b77cfcd169ab4aed3cb2b5aa9d961.zip
cpython-c20ed51dc38b77cfcd169ab4aed3cb2b5aa9d961.tar.gz
cpython-c20ed51dc38b77cfcd169ab4aed3cb2b5aa9d961.tar.bz2
Named tuple is a concept, not a specific type.
Diffstat (limited to 'Doc/glossary.rst')
-rw-r--r--Doc/glossary.rst16
1 files changed, 11 insertions, 5 deletions
diff --git a/Doc/glossary.rst b/Doc/glossary.rst
index 307bad3..9aa2d7e 100644
--- a/Doc/glossary.rst
+++ b/Doc/glossary.rst
@@ -340,11 +340,17 @@ Glossary
also :term:`immutable`.
named tuple
- A tuple subclass whose elements also are accessible as attributes via
- fixed names (the class name and field names are indicated in the
- individual documentation of a named tuple type, like ``TestResults(failed,
- attempted)``). Named tuple classes are created by
- :func:`collections.namedtuple`.
+ Any tuple-like class whose indexable fields are also accessible with
+ named attributes (for example, :func:`time.localtime` returns a
+ tuple-like object where the *year* is accessable either with an
+ index such as ``t[0]`` or with a named attribute like ``t.tm_year``).
+
+ A named tuple can be a built-in type such as :class:`time.struct_time`,
+ or it can be created with a regular class definition. A full featured
+ named tuple can also be created with the factory function
+ :func:`collections.namedtuple`. The latter approach automatically
+ provides extra features such as a self-documenting representation like
+ ``Employee(name='jones', title='programmer')``.
namespace
The place where a variable is stored. Namespaces are implemented as