[docs] [issue21195] None float format: incomplete documentation

Eric V. Smith report at bugs.python.org
Thu Apr 10 17:04:53 CEST 2014


Eric V. Smith added the comment:

The rule is:
- if the entire format specifier is the empty string (not None, but ''), then return str(value)
- else, look at the presentation type. if it is missing, set it to something like 'g'
- do the normal float formatting using the presentation type

The first of these has an empty string for the format specifier (so uses str(1e10), the rest do not:

>>> format(1e10, '')
'10000000000.0'
>>> format(1e10, ' ')
' 10000000000.0'
>>> format(1e10, ' g')
' 1e+10'
>>> format(1e10, ' e')
' 1.000000e+10'
>>> format(1e10, ' f')
' 10000000000.000000'

Now, how much the "something like g" part of the above is true is debatable.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21195>
_______________________________________


More information about the docs mailing list