code: def set_terminal_title(title, kernel32=None):
      
      try:
          title_bytes = title.encode('utf-8')
      except AttributeError:
          title_bytes = title
  
      if IS_WINDOWS:
          kernel32 = kernel32 or ctypes.windll.kernel32
          try:
              is_ascii = all(ord(c) < 128 for c in title)  # str/unicode.
          except TypeError:
              is_ascii = all(c < 128 for c in title)  # bytes.
          if is_ascii:
              return kernel32.SetConsoleTitleA(title_bytes) != 0
          else:
              return kernel32.SetConsoleTitleW(title) != 0
  
      # Linux/OSX.
      sys.stdout.write(b'\033]0;' + title_bytes + b'\007')
      return True
docs: Set the terminal title.
  
      :param title: The title to set (string, unicode, bytes accepted).
      :param kernel32: Optional mock kernel32 object. For testing.
  
      :return: If title changed successfully (Windows only, always True on Linux/OSX).
      :rtype: bool