[Python-ideas] Improve readability of long numeric literals

Ethan Furman ethan at stoneleaf.us
Tue Feb 9 20:07:53 EST 2016


To excerpt the email I referred to earlier:

Guido said:
----------
> Fine points about _ in floats: IMO the _ should be allowed to appear
> between any two digits, or between the last digit and the 'e' in the
> exponent, or between the 'e' and a following digit. But not adjacent
> to the '.' or to the '+' or '-' in the exponent. So 3.141_593 yes,
> 3_.14 no.
>
> Fine points about _ in bin/oct/hex literals: 0x_dead_beef yes, 0_xdeadbeef no.
>
> (The overall rule seems to be that it must be internal to alphanumeric
> strings, except that leading 0x, 0o or 0b must not be separated --
> somehow I find 0_x_dead_beef would be a disservice to human readers.)

and in talking about int() accepting underscored inputs:

> It seems entirely harmless here. Also for float().

--
~Ethan~


More information about the Python-ideas mailing list