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.

ChrisA
_______________________________________________
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/LA3UGPBZYV3ODLEIUDUP26J43IHS56LI/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to