string formatting: engineering notation
Steve Holden
steve at holdenweb.com
Wed Mar 14 16:54:15 EDT 2007
Darren Dale wrote:
> Does anyone know if it is possible to represent a number as a string with
> engineering notation (like scientific notation, but with 10 raised to
> multiples of 3: 120e3, 12e-6, etc.). I know this is possible with the
> decimal.Decimal class, but repeatedly instantiating Decimals is inefficient
> for my application (matplotlib plotting library). If it is not currently
> possible, do you think the python devs would be receptive to including
> support for engineering notation in future releases?
>
How close is this:
>>> "%.3e" % 3.14159
'3.142e+00'
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Blog of Note: http://holdenweb.blogspot.com
See you at PyCon? http://us.pycon.org/TX2007
More information about the Python-list
mailing list