code: def _compute_comparator(string, idx):
      # type: (str, int) -> Optional[Callable[[Any, Any], bool]]
      
      part1 = string[idx]
      try:
          part2 = string[idx + 1]
      except IndexError:
          # String is too short (no comparison)
          return None
  
      if part1 == "=":
          # Equality
          return _comparator_eq
      elif part2 != "=":
          # It's a "strict" operator
          if part1 == "<":
              # Strictly lesser
              return _comparator_lt
          elif part1 == ">":
              # Strictly greater
              return _comparator_gt
      else:
          if part1 == "<":
              # Less or equal
              return _comparator_le
          elif part1 == ">":
              # Greater or equal
              return _comparator_ge
          elif part1 == "~":
              # Approximate equality
              return _comparator_approximate
      return None
docs: Tries to compute the LDAP comparator at the given index
  
      Valid operators are :
  
      * = : equality
      * <= : less than
      * >= : greater than
      * ~= : approximate
  
      :param string: A LDAP filter string
      :param idx: An index in the given string
      :return: The corresponding operator, None if unknown