[Tutor] re Format a file

prasad rao prasadaraon50 at gmail.com
Fri Feb 27 05:29:40 CET 2009


HelloI don't know why, but this I think going into infinite loop.
I cant see anything wrong in it.
Please show me where  the problem is.

def myform(s):
???? import os
???? so=open(s)
???? d=os.path.dirname(s)+os.sep+'temp.txt'
???? de=open(d,'w')
???? for line in so:
???????? while len(line)>60:
????????????tem=line[60:]
????????????try:
??????????????? a,b=tem.split(' ',1)
??????????????? de.write(line[:60]+a+'\n')
??????????????? line=b
????????????except ValueError:pass
???????? de.write(line+'\n')
???? so.close()
???? de.close()
???? os.remove(s)
???? os.rename(d,s)

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


More information about the Tutor mailing list