mirror of
https://github.com/python/cpython.git
synced 2025-09-30 12:21:51 +00:00
[3.6] bpo-28851: Improve namedtuple documentation (GH-1274) (GH-1286)
Clarify that a sequence of strings is the preferred value for 'field_names'.
(cherry picked from commit 97bf722fcd
)
This commit is contained in:
parent
ea0efa3bc1
commit
16b6f971bd
1 changed files with 3 additions and 3 deletions
|
@ -771,9 +771,9 @@ they add the ability to access fields by name instead of position index.
|
||||||
helpful docstring (with typename and field_names) and a helpful :meth:`__repr__`
|
helpful docstring (with typename and field_names) and a helpful :meth:`__repr__`
|
||||||
method which lists the tuple contents in a ``name=value`` format.
|
method which lists the tuple contents in a ``name=value`` format.
|
||||||
|
|
||||||
The *field_names* are a single string with each fieldname separated by whitespace
|
The *field_names* are a sequence of strings such as ``['x', 'y']``.
|
||||||
and/or commas, for example ``'x y'`` or ``'x, y'``. Alternatively, *field_names*
|
Alternatively, *field_names* can be a single string with each fieldname
|
||||||
can be a sequence of strings such as ``['x', 'y']``.
|
separated by whitespace and/or commas, for example ``'x y'`` or ``'x, y'``.
|
||||||
|
|
||||||
Any valid Python identifier may be used for a fieldname except for names
|
Any valid Python identifier may be used for a fieldname except for names
|
||||||
starting with an underscore. Valid identifiers consist of letters, digits,
|
starting with an underscore. Valid identifiers consist of letters, digits,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue