On Tue, Dec 23, 2008 at 3:10 PM, Matt Herzog <m...@blisses.org> wrote: > for filename in os.listdir(directory): > result = re.match(s, filename) > print result
You never open and read the files. You are searching for the pattern in the filename, not in the contents of the file. If there is no match, result will be None. You need to test it and print it only if it is not None. (Actually I don't think you want to print the match object, you want to print the filename and the line of the file that matches. But one thing at a time...) This test and print should be inside the "for filename" loop; your print statement is outside the loop. Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor