4 ms·
Not ideal, but in my code, I intentionally provoke syntax error near the beginning of the file, with a comment explaining what's going on, e.g.: 0_0 # Pyt
by jwilk 5y ago
Not ideal, but in my code, I intentionally provoke syntax error near the beginning of the file, with a comment explaining what's going on, e.g.:
0_0 # Python >= 3.6 is required
I have a collection of such incantations for many Python versions here:
https://github.com/jwilk/python-syntax-errors https://github.com/jwilk/python-syntax-errors
- tyingq 5y agoAh, thanks. That's short and does almost what I want.
- neoncontrails 5y agoThat's hilarious. Which PEP made 0_0 syntactically okay? I typed it into an AST visualizer (I'm on mobile) and if I'm not mistaken this is equivalent to `0`. But why?
- kuratkull 5y agoUnderscores in Numeric Literals. (PEP 515) https://www.python.org/dev/peps/pep-0515/ https://www.python.org/dev/peps/pep-0515/ Your question about 0_0 is just 00 which is 0. (This is really common in other modern languages. Readable example: 1_000_000 vs 1000000)