How to print floating point in scientific format?

Bengt Richter bokr at oz.net
Sun Aug 10 17:00:54 EDT 2003


On 8 Aug 2003 12:15:53 -0700, sdhyok at yahoo.com (sdhyok) wrote:

>I want to change the DEFAULT behavior of python
>to print out all floating points in scientific format?
>For instance,
>
>>x=0.01
>>print x
>1.000000E-2 #Like print "%E"%x
>
>How can I do it?
>
Do you have to use the print statement per se for output?
I.e., why couldn't you write

    sciPrint( x, whatever, etc )

instead of

    print x, whatever, etc

Then you could customize sciPrint as you please.
Or do you have to change the behaviour of existing modules without
changing their source?

Regards,
Bengt Richter




More information about the Python-list mailing list