Hello
>> for line in so:
>> if len(line)<70:de.write(line+'\n')
>> if len(line)>70:
>> da=textwrap.fill(line,width=60)
>> de.write(da+'\n')
>What happens if the line is exactly 70 characters long?
>I think you want an else instead of the second i
On Fri, Feb 27, 2009 at 5:09 AM, prasad rao wrote:
> Hello
> Finally I managed to writ a function to format a file.
> Thank to everybody for their tips.
>
> def mmm(a):
> import os,textwrap
> so=open(a)
> d=os.path.dirname(a)+os.sep+'temp.txt'
> de=open(d,'w')
> import te
"prasad rao" wrote
for line in so:
if len(line)<70:de.write(line+'\n')
if len(line)>70:
da=textwrap.fill(line,width=60)
de.write(da+'\n')
What happens if the line is exactly 70 characters long?
I think you want an else instead of the second
HelloFinally I managed to writ a function to format a file.
Thank to everybody for their tips.
def mmm(a):
import os,textwrap
so=open(a)
d=os.path.dirname(a)+os.sep+'temp.txt'
de=open(d,'w')
import textwrap
for line in so:
if len(line)<70:de.write(line+'\n'
On Fri, 27 Feb 2009 09:59:40 +0530, prasad rao wrote:
> 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:
> item=line[60:]
> try:
> a
2009/2/27 prasad rao :
> Hello
> I 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.
[...]
> while len(line)>60:
> tem=line[60:]
> try:
> ??? a,b=tem.split(' ',1)
> ?
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:
?