title: Python re.sub not working with colorama and re.compile
body: <p>I have the following program which searches for a string in lines in a certain location and then outputs the search matches. I want to be able to choose whether to ignore case in the search and highlight the search string in the output line.</p>
  
  <pre><code>import re, os, glob  
  from colorama import init, Fore, Back, Style  
  init(autoreset=True)
  
  path = "c:\\temp2"  
  os.chdir(path) 
  
  def get_str(msg):
      myinput = input(msg)
      while True:
          if not bool(myinput):
              myinput = input('No Input..\nDo it again\n--&gt;')
              continue
          else:
              return myinput
  
  ext = get_str('Search the files with the following extension...')
  find = get_str('Search string...')
  case = get_str('    Ignore case of search string? (y/n)...')   
  print()
  
  if case == "y" or case == "Y":
      find = re.compile(find, re.I) 
  else:
      find = find
  
  files_to_search = glob.glob('*.' + ext)
  
  for f in files_to_search:
      input_file = os.path.join(path, f)
      with open(input_file) as fi:
          file_list = fi.read().splitlines() 
          for line in file_list:
              if re.search(find, line):  
                  line = re.sub(find, Fore.YELLOW + find + Fore.RESET, line)
                  print(f, "--", line) 
  </code></pre>
  
  <p>The program works if I select "n" for case. If I select "y" I get this error when the program is run:</p>
  
  <pre><code>Search the files with the following extension...txt  
  Search string...this  
      Ignore case of search string? (y/n)...y  
  
  Traceback (most recent call last):  
    File "C:\7. apps\eclipse\1. workspace\learning\scratch\scratchy.py", line 36, in &lt;module&gt;
      line = re.sub(find, Fore.YELLOW + find + Fore.RESET, line)  
  TypeError: Can't convert '_sre.SRE_Pattern' object to str implicitly   
  </code></pre>
  
  <p>How can I make this work for the "yes" case?</p>