[Tutor] Invisible Characters in Fortran/Python
Tyler Glembo
tglembo at gmail.com
Sun Apr 10 00:12:33 CEST 2011
Hi All,
So I have a ~3000 line fortran code that needs to be updated to run new
files by simply updating a few lines in the code (~10 lines). I thought
python would be a great way to do so since I know a little python but not
fortran. So, my plan was to read in each line, and then at a certain line
number, write out the changed code. A short snippet is as follows:
dest= open( f1, "w" )
source= open( f2, "r" )
for line in source:
if X:
dest.write( newline + "\n" )
else:
dest.write( line )
dest.close()
source.close()
The problem I am having is with hidden/invisible character. In the fortran
code, there are line indents which are denoted with an invisible character
^I. When I write with python, there is no ^I at the beginning of the line
and the fortran code no longer compiles. I know how to put in the invisible
line return character (\n), but how can I put in other invisible characters?
Thank you kindly,
Tyler
P.S. In VI when I "set invlist" the hidden character ^I shows up in blue at
the beginning of the line in place of 4 red spaces that are normally there.
I'm assuming it is like a tab indent, but I don't know what it is.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110409/2e43abc5/attachment.html>
More information about the Tutor
mailing list