Underscores in Python numbers
iddw at hotmail.com
Sat Nov 19 01:03:46 CET 2005
Sorry for the delayed response. I somehow missed this earlier.
On Tue, 8 Nov 2005 15:39:09 +0000 (UTC) in comp.lang.python,
roy at panix.com (Roy Smith) wrote:
>Dave Hansen <iddw at hotmail.com> wrote:
>> Of course, I write _far_ more code in C than Python. But I've seen
>> enough bugs of the sort where someone wrote 1200000 when they meant
Digression: 1 was enough.
>> 12000000, that I see great value in being able to specify 12_000_000.
>I'll admit that being able to write 12_000_000 would be convenient.
>On the other hand, writing 12 * 1000 * 1000 is almost as clear. In C,
Perhaps, but it's pretty obvious that something's wrong when you have
to resort to ugly tricks like this to make the value of a simple
integer constant "clear."
And think about 64 (or longer) -bit unsigned long long hexadecimal
values. How much nicer is 0xFFF0_FF0F_F0FF_0FFF_ULL than
0xFFF0FF0FF0FF0FFFULL? I guess we could do something like
((((0xFFF0ULL<<16)|0xFF0FULL)<<16)|0xF0FFULL)<<16)|0x0FFFULL), but I'm
not sure it's any better.
Change is inevitable, progress is not.
More information about the Python-list