[Tutor] file read - rewind?

vicki at thepenguin.org vicki at thepenguin.org
Mon Jul 26 18:06:57 CEST 2004

I want to read in a file, act on each line of the file, and then start at
the beginning again. I don't see a rewind function in the fileinput
module, yet it still does not work by simply executing the for line in
inputfile again. What am I missing? The while loop should repeat until
STOP_READ is set to TRUE.


        STOP_READ = wx.FALSE
        first_iteration = wx.TRUE
        #While not STOP_READ, iterate through lines in file
        while STOP_READ == wx.FALSE or first_iteration == wx.TRUE:
            print "Got into while loop"
            for line in input.readlines():
                if len(line)>1:
                    first_iteration == wx.FALSE

                    self.command = tokens[0][0]+tokens[0][1]
                    self.arguments =
tokens[0].lstrip(tokens[0][0]+tokens[0][1]+" ")
                    print self.command
                    print self.arguments
                    self.ProcessCommand(self.command, self.arguments)

More information about the Tutor mailing list