Underscores in Python numbers

Mike Meyer mwm at mired.org
Sat Nov 19 23:08:38 EST 2005


Steven D'Aprano <steve at REMOVETHIScyber.com.au> writes:
> On Sat, 19 Nov 2005 13:08:57 -0500, Peter Hansen wrote:
>> Umm... in other words, "the underscore is under-used so let's assign 
>> some arbitrary meaning to it" (to make the language more like Perl 
>> perhaps?).
>
> +1
>
> I *really* don't like the idea of allowing underscores in numeric
> literals. Firstly, for aesthetic reasons: I think 123_456 is seriously
> ugly. Secondly, for pragmatic reasons, I think it is too easy to mistype
> as 123-456. I know that Python can't protect you from typing 9-1 instead
> of 901, but why add special syntax that makes that sort of error MORE
> common?)

I've seen at least one language (forget which one) that allowed such
separators, but only for groups of three. So 123_456 would be valid,
but 9_1 would be a syntax error. This kind of thing might help with
the detecting typos issue, and probably won't be noticed by most
users.

        <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list