From c20ed51dc38b77cfcd169ab4aed3cb2b5aa9d961 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sun, 13 Jan 2008 06:15:15 +0000 Subject: Named tuple is a concept, not a specific type. --- Doc/glossary.rst | 16 +++++++++++----- 1 file 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 -- cgit v0.12