def flagmkey (filepath) : """add file to mrobotList if it doesn't contain name=keywords tag""" file = open(filepath, 'rb') html = file.read() file.close() p = re.compile(r'keywords', re.IGNORECASE) if p.match(html): print 'match' return else: print 'no match' mkeyList.append(filepath)