code: def replace_handler(logger, match_handler, reconfigure):
      
      handler, other_logger = find_handler(logger, match_handler)
      if handler and other_logger and reconfigure:
          # Remove the existing handler from the logger that its attached to
          # so that we can install a new handler that behaves differently.
          other_logger.removeHandler(handler)
          # Switch to the logger that the existing handler was attached to so
          # that reconfiguration doesn't narrow the scope of logging.
          logger = other_logger
      return handler, logger
docs: Prepare to replace a handler.
  
      :param logger: Refer to :func:`find_handler()`.
      :param match_handler: Refer to :func:`find_handler()`.
      :param reconfigure: :data:`True` if an existing handler should be replaced,
                          :data:`False` otherwise.
      :returns: A tuple of two values:
  
                1. The matched :class:`~logging.Handler` object or :data:`None`
                   if no handler was matched.
                2. The :class:`~logging.Logger` to which the matched handler was
                   attached or the logger given to :func:`replace_handler()`.