Underscores in Python numbers

Steven D'Aprano steve at REMOVETHIScyber.com.au
Sun Nov 20 17:09:06 EST 2005


On Sun, 20 Nov 2005 15:52:29 -0500, Roy Smith wrote:

> You have described, if memory serves, a Taylor series, and those 
> coefficients are 1/3!, 1/5!, 1/7!, etc.  What I would do, rather than 
> embedding the numeric constants in the code, is embed the formula and have 
> the machine compute the actual values at import time.  At the very least, 
> have them machine generated and saved.  You certainly don't want to be 
> typing in long strings of digits like that.

Not all numeric constants used have simple formulae, or *any* formulae, or
can be calculated on the fly in any reasonable time. Numeric programming
often uses magic constants which truly are "magic" (in the sense that
where they come from requires deep, difficult, and sometimes hidden
knowledge).

Nobody sensible wants to be typing in long strings of digits, but
sometimes it is unavoidable.

-- 
Steven.




More information about the Python-list mailing list