Numeric literal syntax

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Thu Sep 4 03:27:05 CEST 2008


Alexander Schmolck:
> It also reads well, unlike the underscore
> which is visually obstrusive and ugly (compare 123'456'890 to 123_456_789).

I like that enough, in my language that symbol is indeed the standard
one to separate thousands, in large numbers. It's light, looks
natural, and as you say it's visually unobstrusive.

But in my language ' means just thousands, so it's used only in blocks
of 3 digits, not in blocks of any length, so something like this looks
a bit strange/wrong:

0b'0000'0000

While the underscore has no meaning, so it can be used in both
situations.

A problem is that '1234' in Python is a string, so using ' in numbers
looks a bit dangerous to me (and my editor will color those numbers as
alternated strings, I think).

Note that for other people the ' denotes feet, while in my language it
denotes minutes, while I think the underscore has no meaning.

So for me the underscore is better :-)

Bye,
bearophile



More information about the Python-list mailing list