Hello I'd just like to open each file in a directory with a given extension, read it to search for a pattern, and, if not found, append data to this file. The following doesn't work:
====== import glob,re f = open("activate.tmpl", "r") template = f.read() template = "\r\n" + template f.close() for file in glob.glob('*.frm'): #BAD f = open(file, "r+") #f = open(file, "r") #f = open(file, "a") f = open(file, "rw") if not re.search('Form_Activate',f.read(), re.I): #print "Not in " + file #IOError: [Errno 0] Error f.write(template) f.close() ====== What am I doing wrong? Thank you. -- http://mail.python.org/mailman/listinfo/python-list