@@ -735,17 +735,28 @@ Glossary
735735 also :term: `immutable `.
736736
737737 named tuple
738- Any tuple-like class whose indexable elements are also accessible using
739- named attributes (for example, :func: `time.localtime ` returns a
740- tuple-like object where the *year * is accessible either with an
741- index such as ``t[0] `` or with a named attribute like ``t.tm_year ``).
742-
743- A named tuple can be a built-in type such as :class: `time.struct_time `,
744- or it can be created with a regular class definition. A full featured
745- named tuple can also be created with the factory function
746- :func: `collections.namedtuple `. The latter approach automatically
747- provides extra features such as a self-documenting representation like
748- ``Employee(name='jones', title='programmer') ``.
738+ The term "named tuple" applies to any type or class that inherits from
739+ tuple and whose indexable elements are also accessible using named
740+ attributes. The type or class may have other features as well.
741+
742+ Several built-in types are named tuples, including the values returned
743+ by :func: `time.localtime ` and :func: `os.stat `. Another example is
744+ :data: `sys.float_info `::
745+
746+ >>> sys.float_info[1] # indexed access
747+ 1024
748+ >>> sys.float_info.max_exp # named field access
749+ 1024
750+ >>> isinstance(sys.float_info, tuple) # kind of tuple
751+ True
752+
753+ Some named tuples are built-in types (such as the above examples).
754+ Alternatively, a named tuple can be created from a regular class
755+ definition that inherits from :class: `tuple ` and that defines named
756+ fields. Such as class can be written by hand or it can be created with
757+ the factory function :func: `collections.namedtuple `. The latter
758+ technique also adds some extra methods that may not be found in
759+ hand-written or built-in named tuples.
749760
750761 namespace
751762 The place where a variable is stored. Namespaces are implemented as
@@ -1028,14 +1039,6 @@ Glossary
10281039 an :term: `expression ` or one of several constructs with a keyword, such
10291040 as :keyword: `if `, :keyword: `while ` or :keyword: `for `.
10301041
1031- struct sequence
1032- A tuple with named elements. Struct sequences expose an interface similar
1033- to :term: `named tuple ` in that elements can be accessed either by
1034- index or as an attribute. However, they do not have any of the named tuple
1035- methods like :meth: `~collections.somenamedtuple._make ` or
1036- :meth: `~collections.somenamedtuple._asdict `. Examples of struct sequences
1037- include :data: `sys.float_info ` and the return value of :func: `os.stat `.
1038-
10391042 text encoding
10401043 A codec which encodes Unicode strings to bytes.
10411044
0 commit comments