[Python-Dev] format specification mini-language docs... (original) (raw)

Dino Viehland dinov at microsoft.com
Sat Nov 22 01:51:50 CET 2008


Ok, now I'm implementing format support for IronPython. The format spec mini-language docs say that a presentation type of None is the same as 'g' for floating point / decimal values. But these two formats seem to differ based upon how they handle whole numbers:

2.0.format('') '2.0' 2.0.format('g') '2'

The docs also say that 'g' prints it as fixed point unless the number is too large. But the fixed point format differs from what 'f' would print. I guess it didn't say they'd both print it as fixed point w/ a precision of 6 or anything but it seems a little unclear.

2.0.format('g') '2' 2.0.format('f') '2.000000'

Finally providing any sign character seems to cause +1.0#INF and friends to be returned instead of inf as is documented:

10e667.format('+') '+1.0#INF' 10e667.format('') 'inf'

Are these just doc bugs? The inf issue is the only one that seems particularly weird to me.



More information about the Python-Dev mailing list