Anonymous avatar Anonymous committed b367b53

New string format character.

Comments (0)

Files changed (1)

Doc/whatsnew/3.2.rst

   >>> short.untransform('zlib_codec')
   b'which witch had which witches wrist watch'
 
-  (From multiple contributers in :issue:`7475`.)
+  (From multiple contributors in :issue:`7475`.)
+
+* String formatting for :func:`format` and :meth:`str.format` gained a new format
+  character **#**.  For integers in binary, octal, or hexadecimal, it causes
+  the output to be prefixed with  '0b', '0o', or '0x' respectively.  For floats,
+  complex, and Decimal, it causes the output to always have a decimal point
+  even when no digits follow it.
+
+  >>> format(20, '#o')
+  '0o24'
+  >>> format(12.34, '#5.0f')
+  '  12.'
+
+  (Suggested by Mark Dickinson and implemented by Eric Smith in :issue:`7094`.)
 
 * The interpreter can now be started with a quiet option, ``-q``, to suppress
   the copyright and version information in an interactive mode.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.