From 49a58e360abadeb9823afbbfbe1f31f25057751c Mon Sep 17 00:00:00 2001 From: Tal Einat <532281+taleinat@users.noreply.github.com> Date: Thu, 6 May 2021 15:55:12 +0300 Subject: [PATCH 1/2] clearly document that ":#X" string formatting results in "0X..." --- Doc/library/string.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Doc/library/string.rst b/Doc/library/string.rst index d935419f7b75e7..5c9d0b7294f8ec 100644 --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -386,8 +386,8 @@ The ``'#'`` option causes the "alternate form" to be used for the conversion. The alternate form is defined differently for different types. This option is only valid for integer, float and complex types. For integers, when binary, octal, or hexadecimal output -is used, this option adds the prefix respective ``'0b'``, ``'0o'``, or -``'0x'`` to the output value. For float and complex the +is used, this option adds the respective prefix ``'0b'``, ``'0o'``, +``'0x'`` or ``'0X'`` to the output value. For float and complex the alternate form causes the result of the conversion to always contain a decimal-point character, even if no digits follow it. Normally, a decimal-point character appears in the result of these conversions @@ -467,6 +467,8 @@ The available integer presentation types are: +---------+----------------------------------------------------------+ | ``'X'`` | Hex format. Outputs the number in base 16, using | | | upper-case letters for the digits above 9. | + | | In case ``'#'`` is specified, the prefix ``'0x'`` will | + | | be upper-cased to ``'0X'`` as well. | +---------+----------------------------------------------------------+ | ``'n'`` | Number. This is the same as ``'d'``, except that it uses | | | the current locale setting to insert the appropriate | From fdccf950c8c2ce7d28a11856a7ae19caed3db114 Mon Sep 17 00:00:00 2001 From: Tal Einat <532281+taleinat@users.noreply.github.com> Date: Thu, 6 May 2021 16:06:02 +0300 Subject: [PATCH 2/2] put back the "serial comma" --- 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 5c9d0b7294f8ec..b27782f8d8e9b4 100644 --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -387,7 +387,7 @@ conversion. The alternate form is defined differently for different types. This option is only valid for integer, float and complex types. For integers, when binary, octal, or hexadecimal output is used, this option adds the respective prefix ``'0b'``, ``'0o'``, -``'0x'`` or ``'0X'`` to the output value. For float and complex the +``'0x'``, or ``'0X'`` to the output value. For float and complex the alternate form causes the result of the conversion to always contain a decimal-point character, even if no digits follow it. Normally, a decimal-point character appears in the result of these conversions