[Python-bugs-list] fpformat (PR#74)

stockbridgen@cder.fda.gov stockbridgen@cder.fda.gov
Fri, 10 Sep 1999 07:34:14 -0400 (EDT)


Full_Name: Norman Stockbridge
Version: 1.5.2
OS: Win95
Submission from: defender.fda.gov (198.77.181.2)


I'm new to Python, so maybe no one really uses fpformat, but I needed a
scientific notation formatted string. When fpformat.sci() is passed an arg
ALREADY in sci notation of the usual format, it produces either a correct
answer, an incorrect answer, or raises an exception, depending on the absolute
value of the exponent. The exponent is picked out and passed to eval(), but if
the exponent has a leading zero, eval() will attempt to interpret the exponent
as an octal number. Thus '1.23e005' and '1.23e-007' are interpreted correctly,
'1.23e010' and '1.23e-017' are interpreted incorrectly (as 1.23e8 and 1.23e-15),
and '1.23e-008' and '1.23e019' bomb.
My work-around is not to pass in anything already in scientific notation.