From 3bb31f58036897612ccb464612da4aa68d42e05a Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Sat, 1 Mar 2025 06:28:40 +0300 Subject: [PATCH 1/2] gh-130662: refine width/precision specification in format-spec --- Doc/library/string.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Doc/library/string.rst b/Doc/library/string.rst index 721c5c8d334674..d2038b00234623 100644 --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -327,9 +327,10 @@ The general form of a *standard format specifier* is: width_and_precision: [`width_with_grouping`][`precision_with_grouping`] width_with_grouping: [`width`][`grouping_option`] precision_with_grouping: "." [`precision`]`grouping_option` - width: `~python-grammar:digit`+ grouping_option: "_" | "," - precision: `~python-grammar:digit`+ + width: `digits` + precision: `digits` + digits: `~python-grammar:nonzerodigit` `~python-grammar:digit`* type: "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" : | "G" | "n" | "o" | "s" | "x" | "X" | "%" From 6e50636209fbcf8ade5ef5ea1fa0df74dd1a5c19 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Sat, 1 Mar 2025 06:53:42 +0300 Subject: [PATCH 2/2] +1 --- Doc/library/string.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/string.rst b/Doc/library/string.rst index d2038b00234623..836599bace231f 100644 --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -328,8 +328,8 @@ The general form of a *standard format specifier* is: width_with_grouping: [`width`][`grouping_option`] precision_with_grouping: "." [`precision`]`grouping_option` grouping_option: "_" | "," - width: `digits` - precision: `digits` + width: "0" | `digits` + precision: "0" | `digits` digits: `~python-grammar:nonzerodigit` `~python-grammar:digit`* type: "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" : | "G" | "n" | "o" | "s" | "x" | "X" | "%"