[Python-ideas] Improve readability of long numeric literals
Andrew Barnert
abarnert at yahoo.com
Tue Feb 9 20:45:11 EST 2016
On Feb 9, 2016, at 16:45, MRAB <python at mrabarnett.plus.com> wrote:
>
> The Ada programming language allows underscores in numerals, but requires there to be a digit on both sides of the underscore.
I think Swift, Ruby, and most other languages allow runs of multiple underscores, and even trailing underscores.
It seems like it's a lot easier to lex "digit (digit-or-underscore)*", "0x (hex-digit-or-underscore)+", etc. than to try to add restrictions. And not just for Python itself, but for anyone who wants to write a Python tokenizer or parser. And it's a shorter rule to document, and easier to remember. So, unless there's a really compelling reason for an extra restriction, I think it's better to leave the restrictions out (and make them style issues).
More information about the Python-ideas
mailing list