Skip to content

Commit 99bfc56

Browse files
committed
gh-61449: document present 0-padding option behavior for builtin numeric types
1 parent 66eafc9 commit 99bfc56

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Doc/library/string.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,12 @@ The *width* is a decimal integer defining the minimum total field width,
428428
including any prefixes, separators, and other formatting characters.
429429
If not specified, then the field width will be determined by the content.
430430

431-
When no explicit alignment is given, preceding the *width* field by a zero
432-
(``'0'``) character enables sign-aware zero-padding for numeric types,
433-
excluding :class:`complex`. This is equivalent to a *fill* character of
434-
``'0'`` with an *alignment* type of ``'='``.
431+
When no explicit *fill* character and/or alignment is given, preceding the
432+
*width* field by a zero (``'0'``) character enables sign-aware zero-padding for
433+
numeric types, excluding :class:`complex`. This is equivalent to a *fill*
434+
character of ``'0'`` with an *alignment* type of ``'='``. If *fill* character
435+
is specified, ``'0'`` option is ignored. If alignment is explicitly specified,
436+
it's value take preference over provided by ``'0'`` option.
435437

436438
.. versionchanged:: 3.10
437439
Preceding the *width* field by ``'0'`` no longer affects the default

0 commit comments

Comments
 (0)