summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2010-12-05 06:35:16 (GMT)
committerRaymond Hettinger <python@rcn.com>2010-12-05 06:35:16 (GMT)
commite5e728babd88a1ce2654a12b7fd4973f601106a4 (patch)
tree50416db69bda8b8f5237a33f9dcbe76261cfc5da
parentd8fae4e6ad466922422eaa1ff2ac4bc21e1e13d6 (diff)
downloadcpython-e5e728babd88a1ce2654a12b7fd4973f601106a4.zip
cpython-e5e728babd88a1ce2654a12b7fd4973f601106a4.tar.gz
cpython-e5e728babd88a1ce2654a12b7fd4973f601106a4.tar.bz2
New string format character.
-rw-r--r--Doc/whatsnew/3.2.rst15
1 files changed, 14 insertions, 1 deletions
diff --git a/Doc/whatsnew/3.2.rst b/Doc/whatsnew/3.2.rst
index 284c04c..6a92569 100644
--- a/Doc/whatsnew/3.2.rst
+++ b/Doc/whatsnew/3.2.rst
@@ -315,7 +315,20 @@ Some smaller changes made to the core Python language are:
>>> 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.