This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients eric.smith, mark.dickinson, skrah
Date 2009-09-09.19:25:18
SpamBayes Score 6.1200073e-10
Marked as misclassified No
Message-id <1252524321.55.0.725741306888.issue6871@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2009-09-09 19:25:21mark.dickinsonsetrecipients: + mark.dickinson, eric.smith, skrah
2009-09-09 19:25:21mark.dickinsonsetmessageid: <1252524321.55.0.725741306888.issue6871@psf.upfronthosting.co.za>
2009-09-09 19:25:19mark.dickinsonlinkissue6871 messages
2009-09-09 19:25:18mark.dickinsoncreate