The `eval(repr(x)) == x` is not a segment of my code; rather it is part of Python's description of what 'repr' should do:

https://docs.python.org/3.4/library/functions.html?highlight=repr#repr


Specifically: ` For many types, this function makes an attempt to return a string that would yield an object with the same value when passed to eval()`

So everyone in this thread can stop mentioning security concerns; I'm sure we're all aware of those and we should instead focus on what repr should do and shouldn't do.

I think it's weird to not fulfill this promise, when it should be easy to do. Further, I agree that 'inf' is:
  1. Too backwards incompatible
  2. Not the right format for Python (Python likes pascalcase, like `None`, `True`, `False`)

So again, I'd like to not focus on arguing whether a particular codebase should be using 'eval' on strings generated by repr.
Rather, my point was that the current behavior does not follow what Python suggests and says 'repr' should do.


----
Cade Brown
Research Assistant @ ICL (Innovative Computing Laboratory)
Personal Email: brown.cade@gmail.com
ICL/College Email: cade@utk.edu




On Fri, Sep 4, 2020 at 9:31 PM Greg Ewing <greg.ewing@canterbury.ac.nz> wrote:
On 5/09/20 10:51 am, Chris Angelico wrote:
> If you make "inf" a keyword, then even the Python
> standard library is broken.

The OP didn't suggest that, he suggested adding a new name
such as Infinity that reprs could use.

--
Greg
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/TTFTEBD437MK4BCVET7SGUEVJYS6ZET6/
Code of Conduct: http://python.org/psf/codeofconduct/