Skip to content

Commit 3e7316d

Browse files
achhinaambvJelleZijlstra
authored
GH-95088: Clarify rules for parsing an item key for format strings (#103779)
Co-authored-by: Łukasz Langa <[email protected]> Co-authored-by: Jelle Zijlstra <[email protected]>
1 parent 9a89f1b commit 3e7316d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Doc/library/string.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,9 @@ See also the :ref:`formatspec` section.
227227

228228
The *field_name* itself begins with an *arg_name* that is either a number or a
229229
keyword. If it's a number, it refers to a positional argument, and if it's a keyword,
230-
it refers to a named keyword argument. If the numerical arg_names in a format string
230+
it refers to a named keyword argument. An *arg_name* is treated as a number if
231+
a call to :meth:`str.isdecimal` on the string would return true.
232+
If the numerical arg_names in a format string
231233
are 0, 1, 2, ... in sequence, they can all be omitted (not just some)
232234
and the numbers 0, 1, 2, ... will be automatically inserted in that order.
233235
Because *arg_name* is not quote-delimited, it is not possible to specify arbitrary

0 commit comments

Comments
 (0)