[Python-Dev] One more proposed formatting change for 3.1
Mark Dickinson
dickinsm at gmail.com
Tue Apr 28 13:56:59 CEST 2009
Here's one more proposed change, this time for formatting
of floats using format() and the empty presentation type.
To avoid repeating myself, here's the text from the issue
I just opened:
http://bugs.python.org/issue5864
"""
In all versions of Python from 2.6 up, I get the following behaviour:
>>> format(123.456, '.4')
'123.5'
>>> format(1234.56, '.4')
'1235.0'
>>> format(12345.6, '.4')
'1.235e+04'
The first and third results are as I expect, but the second is somewhat
misleading: it gives 5 significant digits when only 4 were requested,
and moreover the last digit is incorrect.
I propose that Python 2.7 and Python 3.1 be changed so that the output
for the second line above is '1.235e+03'.
"""
This issue seems fairly clear cut to me, and I doubt that there's been
enough uptake of 'format' yet for this to risk significant breakage. So
unless there are objections I'll plan to make this change before this
weekend's beta.
Mark
More information about the Python-Dev
mailing list