How to print floating point in scientific format?

John Roth newsgroups at jhrothjr.com
Fri Aug 8 19:21:04 EDT 2003


"sdhyok" <sdhyok at yahoo.com> wrote in message
news:420ced91.0308081115.7060e551 at posting.google.com...
> 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?
>
> Daehyok Shin

To the best of my knowledge, you can't. I believe the
only way to actually control the format is with the '%'
operator.

Of course, if you want to get the source, make the
change, and then have your own private copy of Python,
you could manage it.

John Roth






More information about the Python-list mailing list