[Python-ideas] Improve readability of long numeric literals

Stephen J. Turnbull stephen at xemacs.org
Tue Feb 9 23:11:38 EST 2016


Andrew Barnert via Python-ideas writes:

 > One possible objection that nobody's raised:
 > 
 > Separating groups of three is all well and good; to my western
 > eyes, 10_000_000_000 is obviously 10 billion.*
 > 
 > But someone from China is likely to use groups of four, and
 > 100_0000_0000 is not obviously anything--my first thought is around
 > 100 billion, but that can't be right, so I have to count up the
 > digits.

Not a problem for me any more, that's quite obviously "100-oku" (and
if the unit is "yen", that roughly converts to USD100 million, very
convenient).  I suspect others will learn equally quickly if this
becomes at all common and they need to read "Chinese" or "Japanese"
code where it's used.

Anyway, for me (YMMV) this really is a for-the-writer readability
problem.  Personally I can't imagine using it except interactively.
If I think a number needs checking, I make it a named value, and often
computed.  (Eg, the OP's example would be 1 << 26).




More information about the Python-ideas mailing list