On 1/21/2020 1:32 PM, Chris Angelico wrote:
On Wed, Jan 22, 2020 at 4:03 AM Eric V. Smith <e...@trueblade.com> wrote:
The reason repr adds the '.0' that 'g' does not is to avoid this problem:

  >>> type(eval(repr(17.0))) == type(17.0)
True
  >>> type(eval(format(17.0, '.17g'))) == type(17.0)
False

The OP wasn't asking about eval, though, but about float. If you're
depending on the ability to eval the repr of a float, you also have to
concern yourself with inf and nan, which are not builtin names. But I
believe float(repr(x)) == x for any float x.

None the less, it's why repr adds the '.0' that 'g' does not.

Eric
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/7OMWVNHERBVTS56KD4ENQ4PHYFXXPHFV/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to