On Tue, Sep 8, 2020 at 3:42 PM Christopher Barker email@example.com wrote:
On versions starting with that one, you MUST NOT have that line, as it would be a SyntaxError.
Huh? I was proposing doing it like was done for True and False in Python 2:
They were just builtins, not keywords at all.
but True and False are still "special" at least with ast.literal_eval:
In : ast.literal_eval("[True, False]") Out: [True, False]
I fully agree that this "tiny benefit" is not worth breaking a lot (or hardly any) code. But it seems it can be done with very little breakage.
Yes - literal_eval in Python 2.7 had a whitelist of valid names. Exactly like I'd been suggesting earlier. :) If you want "inf" to be special, write your own literal_eval that treats it as special. It's really not hard. CPython is open source, and the ast module is written in Python, so you can just go look at how it works :)