code: def file_exists(filename):
      
      try:
          return os.path.isfile(filename)
      except (UnicodeDecodeError, UnicodeEncodeError, ValueError):
          return False
docs: Check if a file exists (and don't error out on unicode inputs)