[Tutor] format a file

prasad rao prasadaraon50 at gmail.com
Thu Feb 26 10:09:07 CET 2009


hello
I find it difficult to use horizontal scroll bar to read text documents.
So I want to split lines in the text file in to two lines.

<code>
def  myforrmat(source,desty):
???? so=open(source)
???? de=open(desty,'w')
???? for line in so:
????????? if len(line)<60:de.write(line)
????????? if len(line)>60:
????????????de.write(''.join(list(line)[:60]))
????????????de.write(''.join(list(line)[60:]))
????so.close()
????de.close()
</code>
This code is not working.Destination file have the same length of lines
to source file
Some one please show where the problem is.
I tried to do it using fileinput module and inplace flag. in vain.
please some one show me how to do it.

Thank you
Prasad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090226/700cdcc0/attachment.htm>


More information about the Tutor mailing list