Skip to content

Commit dbb4b48

Browse files
belm0hello-adam
authored andcommitted
[3.9] Corrections to format precision description. (pythonGH-31291) (pythonGH-31321)
* `precision` field is a decimal integer * clarify that stated limitations are on presentation type rather than input value type. Especially misleading is "precision is not allowed for integer values", since integer value input to a format like `.1f` is fine. * regarding max field size, replace "non-number" with "string", which is the only non-numeric presentation type Automerge-Triggered-By: GH:ericvsmith. (cherry picked from commit 1d6ce67) Co-authored-by: John Belmonte <john@neggie.net>
1 parent 2a484f1 commit dbb4b48

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Doc/library/string.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,12 +424,13 @@ When no explicit alignment is given, preceding the *width* field by a zero
424424
sign-aware zero-padding for numeric types. This is equivalent to a *fill*
425425
character of ``'0'`` with an *alignment* type of ``'='``.
426426

427-
The *precision* is a decimal number indicating how many digits should be
428-
displayed after the decimal point for a floating point value formatted with
429-
``'f'`` and ``'F'``, or before and after the decimal point for a floating point
430-
value formatted with ``'g'`` or ``'G'``. For non-number types the field
427+
The *precision* is a decimal integer indicating how many digits should be
428+
displayed after the decimal point for presentation types
429+
``'f'`` and ``'F'``, or before and after the decimal point for presentation
430+
types ``'g'`` or ``'G'``. For string presentation types the field
431431
indicates the maximum field size - in other words, how many characters will be
432-
used from the field content. The *precision* is not allowed for integer values.
432+
used from the field content. The *precision* is not allowed for integer
433+
presentation types.
433434

434435
Finally, the *type* determines how the data should be presented.
435436

0 commit comments

Comments
 (0)