I'm an idiot
David
david_griswold1 at yahoo.com
Fri Jun 28 21:00:22 EDT 2002
OK, I am the first to admit it. I am an idiot. I have RTFM on this over
and over, and I can still not figure out what I am doing wrong.
I think the intent of the code is obvious, but just to clarify, I want to
read every line in a file and write those lines back out to another file,
but with leading and training space removed. I also want to have some
elegant way to determine that I have reached the end of the file and
break out of the loop.
And just to explain my stupidity, my reference langauge is BASIC. I
could have written this in BASIC in a minute, but I need to learn
something new. Any help would be appreciated.
David
f=open('c:\\temp\\temp.txt', 'r')
g=open('c:\\temp\\temp1.txt', 'w')
while 1:
try:
s=f.readline
g.write(s.split())
except IOError:
break
g.close
f.close
More information about the Python-list
mailing list