How to print floating point in scientific format?

sdhyok sdhyok at yahoo.com
Sat Aug 9 10:42:57 EDT 2003


I am disappointed that there is no elegant solution for this problem
in python.
As you may notice, my primary usage of python is for scientific
programming.
For the purpose, it is critical for users to flexibly modify the
printing format
of floating points depending on their ranges and precisions.

Think about this case.

>import Numeric as N
>x = N.arange(10.)
>print x
[ 0.  1.  2.  3.  4.  5.  6.  7.  8.  9.]
>print "%E"%x
TypeError: float argument required

Even the format string option in print command doesn't work for numpy
array.
This limitation can be a serious handicap in the application of python
for scientific programming.
I like to listen to all of you who are interested in this issue.

Shin, Daehyok




More information about the Python-list mailing list