Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Doc/library/string.rst
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ 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: [`~python-grammar:identifier` | `~python-grammar:digit`+]
attribute_name: `~python-grammar:identifier`
arg_name: [`~python-grammar:digit`+ | `attribute_name`]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cf: #151064 (comment)

TL;DR: any str.isdecimal string works for indexing, not just roman decimal digits ("0"..."9") . "١" for example is also valid.

attribute_name: <any source character except "{", "}", "[", or "."> +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
attribute_name: <any source character except "{", "}", "[", or "."> +
attribute_name: <any source character except "{", "}", "[", ".", "!", or ":"> +

"!", ":", and "!" are also invalid attribute names.

element_index: `~python-grammar:digit`+ | `index_string`
index_string: <any source character except "]"> +
conversion: "r" | "s" | "a"
Expand Down
Loading