recursive traversal of file

Xavier Decoret decoret at
Fri Aug 15 21:32:26 CEST 2003

I am reading the lines of a file, executing appropriate command if a 
pattern is found. One of the pattern can be a input command whose effect 
should be to #include the file (possibly recursively)

The main loop looks like this:


     file = open(fileName)
     line = file.readline()
     while line:
         if matchInputPattern(line,inputFile):
              # help me here to parse inputFile
         elif matchDataPattern(line):
         line = file.readline()
except IOError, e:
     print 'I couldn\'t open file name',fileName

Can you tell me if there is a simple way to do the part that says #help 
me!. Should I do a recursive function?

| Xavier Décoret - Post Doct			  |
| Graphics Lab (LCS) - MIT			  |
| mailto: decoret at		  |
| home  :|

More information about the Python-list mailing list