FORTRAN like formatting
Cyril BAZIN
cyril.bazin at gmail.com
Fri Jul 8 14:31:06 EDT 2005
Hello,
I don't anderstand very well Fortran syntax, but want you say
something like that:
def toTable(n1, n2, n3):
return "%20s%20s%20s"%tuple(["%.12f"%x for x in [n1, n2, n3]])
Example:
>>> import math
>>> toTable(math.pi, 10, 8.2323)
' 3.141592653590 10.000000000000 8.232300000000'
If it is not that, please could you give an example of input and
output of your code?
Cyril
On 7/8/05, Einstein, Daniel R <daniel.einstein at pnl.gov> wrote:
>
>
> Hi,
>
> Sorry for this, but I need to write ASCII from my Python to be read by
> FORTRAN and the formatting is very important. Is there any way of doing
> anything like:
>
> write(*,'(3(" ",1pe20.12))') (variable)
>
> In other words, I want three columns 20 spaces long, with 12 digits after
> the decimal and so on and so forth.
>
> What I am really looking for is some general indication of how to do such
> formatting in Python.
>
> Any help?
>
> Dan
>
>
> Daniel R Einstein, PhD
> Biological Monitoring and Modeling
> Pacific Northwest National Laboratory
> P.O. Box 999; MSIN P7-59
> Richland, WA 99352
> Tel: 509/ 376-2924
> Fax: 509/376-9064
> daniel.einstein at pnl.gov
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
More information about the Python-list
mailing list