From d26c42639163dce188e0b5b7ed97207ddce3efcf Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Mon, 10 Mar 2025 10:05:29 +0300 Subject: [PATCH 1/5] gh-130664: specify how thousands separators are used with 0-padding --- Doc/library/string.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Doc/library/string.rst b/Doc/library/string.rst index 721c5c8d334674..a07be55b93c7ce 100644 --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -449,7 +449,9 @@ If not specified, then the field width will be determined by the content. When no explicit alignment is given, preceding the *width* field by a zero (``'0'``) character enables sign-aware zero-padding for numeric types, excluding :class:`complex`. This is equivalent to a *fill* character of -``'0'`` with an *alignment* type of ``'='``. +``'0'`` with an *alignment* type of ``'='``. If thousands separators +are used (as specified either by ``'_'`` or ``','`` option), they placed +also between leading zeros. .. versionchanged:: 3.10 Preceding the *width* field by ``'0'`` no longer affects the default From 3304ed2f5b2cb7a696c6e8d71b10a6772489971e Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Tue, 11 Mar 2025 02:24:30 +0300 Subject: [PATCH 2/5] Update Doc/library/string.rst Co-authored-by: Chris Markiewicz --- 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 a07be55b93c7ce..4b36ef4ced4b84 100644 --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -450,8 +450,8 @@ When no explicit alignment is given, preceding the *width* field by a zero (``'0'``) character enables sign-aware zero-padding for numeric types, excluding :class:`complex`. This is equivalent to a *fill* character of ``'0'`` with an *alignment* type of ``'='``. If thousands separators -are used (as specified either by ``'_'`` or ``','`` option), they placed -also between leading zeros. +are used (as specified either by ``'_'`` or ``','`` option), they are also +placed between leading zeros. .. versionchanged:: 3.10 Preceding the *width* field by ``'0'`` no longer affects the default From 6931a67bc66d1d73a360a28aa3e6d88f1cbdc816 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Sun, 6 Apr 2025 14:21:19 +0300 Subject: [PATCH 3/5] thousands separators -> digit group separators --- Doc/library/string.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/string.rst b/Doc/library/string.rst index e805d8994d51da..7f2546fbfb2ffa 100644 --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -426,9 +426,9 @@ If not specified, then the field width will be determined by the content. When no explicit alignment is given, preceding the *width* field by a zero (``'0'``) character enables sign-aware zero-padding for numeric types, excluding :class:`complex`. This is equivalent to a *fill* character of -``'0'`` with an *alignment* type of ``'='``. If thousands separators -are used (as specified either by ``'_'`` or ``','`` option), they are also -placed between leading zeros. +``'0'`` with an *alignment* type of ``'='``. If digit group separators of the +integral part of a number are used (as specified either by ``','`` or ``'_'`` +option), they are also placed between leading zeros. .. versionchanged:: 3.10 Preceding the *width* field by ``'0'`` no longer affects the default From 71dcf25a2d92afd5a05594466b92ad7401c39a5a Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Mon, 7 Apr 2025 05:03:51 +0300 Subject: [PATCH 4/5] Update Doc/library/string.rst Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- Doc/library/string.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/string.rst b/Doc/library/string.rst index 7f2546fbfb2ffa..d964c523f2cb07 100644 --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -427,7 +427,7 @@ When no explicit alignment is given, preceding the *width* field by a zero (``'0'``) character enables sign-aware zero-padding for numeric types, excluding :class:`complex`. This is equivalent to a *fill* character of ``'0'`` with an *alignment* type of ``'='``. If digit group separators of the -integral part of a number are used (as specified either by ``','`` or ``'_'`` +integral part of a number are used (as specified either by the ``','`` or ``'_'`` option), they are also placed between leading zeros. .. versionchanged:: 3.10 From 4aae176256d40bae94e316fa5496c7564eb93671 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Sat, 2 Aug 2025 16:33:19 +0300 Subject: [PATCH 5/5] address review: don't repeat description of digit group separator --- Doc/library/string.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/string.rst b/Doc/library/string.rst index b7ee41f21fc1de..f17ff137b60d63 100644 --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -431,9 +431,9 @@ If not specified, then the field width will be determined by the content. When no explicit alignment is given, preceding the *width* field by a zero (``'0'``) character enables sign-aware zero-padding for numeric types, excluding :class:`complex`. This is equivalent to a *fill* character of -``'0'`` with an *alignment* type of ``'='``. If digit group separators of the -integral part of a number are used (as specified either by the ``','`` or ``'_'`` -option), they are also placed between leading zeros. +``'0'`` with an *alignment* type of ``'='``. If the *grouping* option for +the integral part is used, a digit group separator is also inserted between +leading zeros. .. versionchanged:: 3.10 Preceding the *width* field by ``'0'`` no longer affects the default