Mark Dickinson <dicki...@gmail.com> added the comment:

Issue #1: In both trunk and py3k I get:

>>> from decimal import Decimal
>>> format(Decimal('nan'), '+08.4')
'    +NaN'
>>> format(float('nan'), '+08.4')
'+0000nan'
>>> format(Decimal('inf'), '+012.4')
'   +Infinity'
>>> format(float('inf'), '+012.4')
'+00000000inf'

Two potential issues here:  first is the zero padding; to me, a zero-
padded nan or inf just looks ugly, but if people think that's the 
correct output (and I suppose that I have to admit that it probably is) 
then I'll add the zeros in for the Decimal type.

The second issue is the difference in spelling; ('nan' versus 'NaN', 
'inf' versus 'Infinity');  I'm not really bothered by this difference, 
and it would be quite awkward to change.  The output format for Decimal 
is mandated by the standard, while changing the spelling for floats 
seems both unnecessary and likely to break code.

Issue #2: This is a bit odd.  If a minimumwidth of 0 is permissible, 
then the format '0' is ambiguous.  Assuming that '0' continues to mean 
zero-padded, this leaves '00' as the *only* way to specify a minimum 
width of 0.  It seems cleaner just to assume that minimumwidth always 
has to be strictly positive, making '00' invalid.  At least, I think 
that's what I was thinking when I wrote the Decimal formatting code.
But I agree that float and Decimal should be consistent here.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue6871>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to