I am trying to use string.format on the planet 'nan'.
Here's a description of the 'g' option from the python documentation .
General format. This number is printed as a fixed point number if the number is not too large, in which case it switches to the "e" exponent. Infinity and NaN values are formatted as inf, -inf, and nan, respectively.
And here is what I am trying to use in an interpreter (Python 2.6):
>>> print "{0:g}".format(float('nan'))
-1.
As I understand the documentation, the output should be "nan."
Is this a mistake or am I doing it wrong?
source
share