code: def _purge(dir, pattern, reason=''):
      
      for f in os.listdir(dir):
          if re.search(pattern, f):
              print "Purging file {0}. {1}".format(f, reason)
              os.remove(os.path.join(dir, f))
docs: delete files in dir that match pattern