summaryrefslogtreecommitdiffstats
path: root/Doc/library/string.rst
diff options
context:
space:
mode:
authorWilliam Andrea <william.j.andrea@gmail.com>2024-01-09 02:47:59 (GMT)
committerGitHub <noreply@github.com>2024-01-09 02:47:59 (GMT)
commitf3d5d4aa8f0388217aeff69e28d078bdda464b38 (patch)
tree40a59b0ce25fa0591ed6ac5be5aa00c30bcd8bcd /Doc/library/string.rst
parenta023bc252dc744736bd21897c5a23a25b800df92 (diff)
downloadcpython-f3d5d4aa8f0388217aeff69e28d078bdda464b38.zip
cpython-f3d5d4aa8f0388217aeff69e28d078bdda464b38.tar.gz
cpython-f3d5d4aa8f0388217aeff69e28d078bdda464b38.tar.bz2
Docs: Link tokens in the format string grammars (#108184)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com> Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Diffstat (limited to 'Doc/library/string.rst')
-rw-r--r--Doc/library/string.rst14
1 files changed, 7 insertions, 7 deletions
diff --git a/Doc/library/string.rst b/Doc/library/string.rst
index 262b785..1867678 100644
--- a/Doc/library/string.rst
+++ b/Doc/library/string.rst
@@ -208,13 +208,13 @@ The grammar for a replacement field is as follows:
.. productionlist:: format-string
replacement_field: "{" [`field_name`] ["!" `conversion`] [":" `format_spec`] "}"
- field_name: arg_name ("." `attribute_name` | "[" `element_index` "]")*
- arg_name: [`identifier` | `digit`+]
- attribute_name: `identifier`
- element_index: `digit`+ | `index_string`
+ field_name: `arg_name` ("." `attribute_name` | "[" `element_index` "]")*
+ arg_name: [`~python-grammar:identifier` | `~python-grammar:digit`+]
+ attribute_name: `~python-grammar:identifier`
+ element_index: `~python-grammar:digit`+ | `index_string`
index_string: <any source character except "]"> +
conversion: "r" | "s" | "a"
- format_spec: <described in the next section>
+ format_spec: `format-spec:format_spec`
In less formal terms, the replacement field can start with a *field_name* that specifies
the object whose value is to be formatted and inserted
@@ -316,9 +316,9 @@ The general form of a *standard format specifier* is:
fill: <any character>
align: "<" | ">" | "=" | "^"
sign: "+" | "-" | " "
- width: `digit`+
+ width: `~python-grammar:digit`+
grouping_option: "_" | ","
- precision: `digit`+
+ precision: `~python-grammar:digit`+
type: "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"
If a valid *align* value is specified, it can be preceded by a *fill*