[Python-checkins] [3.9] Corrections to format precision description. (GH-31291) (GH-31321)
ericvsmith
webhook-mailer at python.org
Sun Feb 13 22:05:20 EST 2022
https://github.com/python/cpython/commit/0b1417d597c9ed5f9cd981fbf62824f41c740b17
commit: 0b1417d597c9ed5f9cd981fbf62824f41c740b17
branch: 3.9
author: John Belmonte <john at neggie.net>
committer: ericvsmith <ericvsmith at users.noreply.github.com>
date: 2022-02-13T22:05:11-05:00
summary:
[3.9] Corrections to format precision description. (GH-31291) (GH-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 1d6ce67c29aa2166ef326952cb605b908fb4f987)
Co-authored-by: John Belmonte <john at neggie.net>
files:
M Doc/library/string.rst
diff --git a/Doc/library/string.rst b/Doc/library/string.rst
index d1bdf4347de19..3ecae27b38577 100644
--- a/Doc/library/string.rst
+++ b/Doc/library/string.rst
@@ -424,12 +424,13 @@ When no explicit alignment is given, preceding the *width* field by a zero
sign-aware zero-padding for numeric types. This is equivalent to a *fill*
character of ``'0'`` with an *alignment* type of ``'='``.
-The *precision* is a decimal number indicating how many digits should be
-displayed after the decimal point for a floating point value formatted with
-``'f'`` and ``'F'``, or before and after the decimal point for a floating point
-value formatted with ``'g'`` or ``'G'``. For non-number types the field
+The *precision* is a decimal integer indicating how many digits should be
+displayed after the decimal point for presentation types
+``'f'`` and ``'F'``, or before and after the decimal point for presentation
+types ``'g'`` or ``'G'``. For string presentation types the field
indicates the maximum field size - in other words, how many characters will be
-used from the field content. The *precision* is not allowed for integer values.
+used from the field content. The *precision* is not allowed for integer
+presentation types.
Finally, the *type* determines how the data should be presented.
More information about the Python-checkins
mailing list