diff options
author | Eric Smith <eric@trueblade.com> | 2008-07-16 00:11:49 (GMT) |
---|---|---|
committer | Eric Smith <eric@trueblade.com> | 2008-07-16 00:11:49 (GMT) |
commit | a5fa5a218d3f37485384948a1033fa5a73c2895c (patch) | |
tree | 9b57d3c4cd78556473fcbe6ee541d81fa2280ac8 /Doc | |
parent | 954a27893951b49e94654b5d20bee606f82d37c6 (diff) | |
download | cpython-a5fa5a218d3f37485384948a1033fa5a73c2895c.zip cpython-a5fa5a218d3f37485384948a1033fa5a73c2895c.tar.gz cpython-a5fa5a218d3f37485384948a1033fa5a73c2895c.tar.bz2 |
Complete issue 3083: add alternate (#) formatting to bin, oct, hex in str.format().
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/string.rst | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Doc/library/string.rst b/Doc/library/string.rst index be9bccb..0e345e3 100644 --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -321,7 +321,7 @@ result as if you had called :func:`str` on the value. The general form of a *standard format specifier* is: .. productionlist:: sf - format_spec: [[`fill`]`align`][`sign`][0][`width`][.`precision`][`type`] + format_spec: [[`fill`]`align`][`sign`][#][0][`width`][.`precision`][`type`] fill: <a character other than '}'> align: "<" | ">" | "=" | "^" sign: "+" | "-" | " " @@ -375,6 +375,10 @@ following: | | positive numbers, and a minus sign on negative numbers. | +---------+----------------------------------------------------------+ +The ``'#'`` option is only valid for integers, and only for binary, +octal, or decimal output. If present, it specifies that the output +will be prefixed by ``'0b'``, ``'0o'``, or ``'0x'``, respectively. + *width* is a decimal integer defining the minimum field width. If not specified, then the field width will be determined by the content. @@ -395,7 +399,7 @@ The available integer presentation types are: +---------+----------------------------------------------------------+ | Type | Meaning | +=========+==========================================================+ - | ``'b'`` | Binary. Outputs the number in base 2. | + | ``'b'`` | Binary format. Outputs the number in base 2. | +---------+----------------------------------------------------------+ | ``'c'`` | Character. Converts the integer to the corresponding | | | unicode character before printing. | |