mirror of
https://github.com/python/cpython.git
synced 2025-09-22 16:33:26 +00:00
Named tuple is a concept, not a specific type.
This commit is contained in:
parent
fca4e1ffa1
commit
c20ed51dc3
1 changed files with 11 additions and 5 deletions
|
@ -340,11 +340,17 @@ Glossary
|
||||||
also :term:`immutable`.
|
also :term:`immutable`.
|
||||||
|
|
||||||
named tuple
|
named tuple
|
||||||
A tuple subclass whose elements also are accessible as attributes via
|
Any tuple-like class whose indexable fields are also accessible with
|
||||||
fixed names (the class name and field names are indicated in the
|
named attributes (for example, :func:`time.localtime` returns a
|
||||||
individual documentation of a named tuple type, like ``TestResults(failed,
|
tuple-like object where the *year* is accessable either with an
|
||||||
attempted)``). Named tuple classes are created by
|
index such as ``t[0]`` or with a named attribute like ``t.tm_year``).
|
||||||
:func:`collections.namedtuple`.
|
|
||||||
|
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
|
namespace
|
||||||
The place where a variable is stored. Namespaces are implemented as
|
The place where a variable is stored. Namespaces are implemented as
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue