[Python-3000] Allowing underscores in numeric constants.

Guido van Rossum guido at python.org
Sun Apr 16 22:16:32 CEST 2006


On 4/15/06, Ian D. Bollinger <ian.bollinger at gmail.com> wrote:
> Personally I like the idea (stolen from Perl, and others) of allowing
> underscores in numbers as to group digits, for instance:
> one_million = 1_000_000
> maximum = 0xFF_FF_FF_FF
>
> Once four or more identical digits appear in a row, I find a number
> starts to become unwieldy, and separators would be a useful visual aid.

I do recall this whas brought up before; I don't recall whether a good
reason was given to kill it apart from that it doesn't add a whole lot
of joy either. There are probably lots of niggling decisions to be
made about whether int("1_000") should work, and a formatting code
that inserts _ every three characters, and whether to accept
abominations like 12__ or 0_x_ff or 3.14_e_1_0_0.

But if someone cares enough to write a PEP that covers all the corner
cases with reasonable rules *and* a complete implementation, it would
be a lot harder to say no.

(See my PS on code vs. PEPs in a previous post in a different thread
on this list.)

--
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list