[issue23602] Implement __format__ for Fraction

Wolfgang Maier report at bugs.python.org
Thu Mar 26 16:09:10 CET 2015


Wolfgang Maier added the comment:

actually, I'm not sure whether formatting Decimals gives correct output under all conditions (correctly rounded yes, but maybe not formatted correctly?).

compare:

>>> format(float('1.481e-6'),'.3g')
'1.48e-06'

>>> format(Decimal('1.481e-6'),'.3g')
'0.00000148'

>>> format(float('1.481e-7'),'.3g')
'1.48e-07'

>>> format(Decimal('1.481e-7'),'.3g')
'1.48e-7'

So with the 'g' specifier the switch between floating point and scientific notation seems to be broken.
Also note the slightly different formatting of the exponent: the leading zero is missing for all specifiers, i.e. 'g', 'G', 'e', 'E'.

Are these bugs ?

----------
nosy: +wolma

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


More information about the Python-bugs-list mailing list