from __future__ import with_statement import os filenames = ['compatibility.h', 'odecpp.h', 'odecpp_collision.h', 'odecpp_old.h', \ 'ode.h'] #files to skip filenames = set(filenames) next_line = 'false' for root, dirs, files in os.walk('/usr/include/ode') : for name in files : if name in filenames: #skip pass else : with open('/usr/include/ode/'+name) as f : #print name for line in f: if line[0:7] == 'ODE_API' or next_line == 'true' : #if next_line == 'true' : # next_line = 'false' print line, line = line[8:] args = line[line.find('('):] if line.find(';') == -1 : next_line = 'true' #print line,