[docs] [issue32737] str.format not producing strings for nan argument in accordance with documentation

D. Michael Parrish report at bugs.python.org
Wed Jan 31 19:08:16 EST 2018


New submission from D. Michael Parrish <will.hill.fx at gmail.com>:

>>> version_info
(3, 0, 1, 'final', 0)
# I know this is an older version---stuck with it at work.
# I did not see this issue in the tracker (380 results for nan).
# Perhaps there is better documentation for how to use the issue
# tracker. Many of the links on the Dealing with Bugs page---
# https://docs.python.org/3/bugs.html#contributing-to-python
# ---are not helpful, e.g., 'contribute' just links back the same
# page.
#
# There are similar problems with inf and -inf
>>> isnan(float('nan'))
True
>>> repr(float('nan'))
'nan'
>>> '{0:f}'.format(float('nan'))
'-1.#IND00'
>>> '{0:F}'.format(float('nan'))
'-1.#IND00'
>>> '{0:g}'.format(float('nan'))
'-1.#IND'
>>> '{0:G}'.format(float('nan'))
'-1.#IND'
>>> '{0:.2f}'.format(float('nan'))
'-1.#J'

# c.f. https://docs.python.org/3/library/string.html#formatspec

----------
assignee: docs at python
components: Documentation
messages: 311393
nosy: ana, docs at python
priority: normal
severity: normal
status: open
title: str.format not producing strings for nan argument in accordance with documentation
type: behavior

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32737>
_______________________________________


More information about the docs mailing list