Underscores in Python numbers

Peter Hansen peter at engcorp.com
Sun Nov 20 03:22:27 CET 2005

Steven D'Aprano wrote:
> Dealing with numeric literals with lots of digits is
> a real (if not earth-shattering) human interface problem: it is hard for
> people to parse long numeric strings.

I'm totally unconvinced that this _is_ a real problem, if we define 
"real" as being even enough to jiggle my mouse, let alone shattering the 

What examples does anyone have of where it is necessary to define a 
large number of large numeric literals?  Isn't it the case that other 
than the odd constants in various programs, defining a large number of 
such values would be better done by creating a data file and parsing it?

And if that's the case, one could easily define any convention one 
desired for formatting the raw data.

And for the odd constant, either take a moment to verify the value, or 
define it in parts (e.g. 24*60*60*1000*1000 microseconds per day), or 
write a nice little variant on int() that can do exactly what you would 
have done for the external data file if you had more values.


More information about the Python-list mailing list