Newbie looking for feedback

David Lees debl.spamnono at world.std.com
Fri Sep 15 00:43:52 EDT 2000


Two questions.  First, I have written a real simple Python routine to
remove blank lines from a text file.  The code below works but...

1. I am sure this can be written much more simply, any hints?
2. Could someone point me to documentation or tell me how to use IDLE
under Windows to single step through the code.  It was a pain debugging
by executing the whole script as a run module command to IDLE.

Thanks in advance.

david lees


import string

fin=open("c:\\foo.txt","r")
fout=open("c:\\barf.txt","w")
s=""

while 1:
    nextln=fin.readline()
    
    if len(nextln)==0 :
        break

    if nextln[0] != '\n' :
        fout.write(nextln)

fin.close()
fout.close()



More information about the Python-list mailing list