[New-bugs-announce] [issue7094] Add alternate float formatting styles to new-style formatting.

Mark Dickinson report at bugs.python.org
Fri Oct 9 21:54:04 CEST 2009

New submission from Mark Dickinson <dickinsm at gmail.com>:

Python's old-style formatting supports the use of an alternative form 
(specified by including a '#' in the format) for 'e', 'f' and 'g' 

Python 3.2a0 (py3k:75275:75276, Oct  7 2009, 20:26:36) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> '%.17g' % 1.2
>>> '%#.17g' % 1.2

New-style formatting doesn't currently support this:

>>> format(1.2, '#.17g')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Alternate form (#) not allowed in float format specifier

To aid migration from old-style to new-style formatting, it might be worth 
adding the alternate forms.  At least the float, complex and Decimal types 
would be affected.

components: Interpreter Core
messages: 93807
nosy: eric.smith, mark.dickinson
severity: normal
stage: test needed
status: open
title: Add alternate float formatting styles to new-style formatting.
type: feature request
versions: Python 3.2

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list