docs: def try_(block, except_=None, else_=None, finally_=None):
      """Emulate a ``try`` block.
  
      :param block: Function to be executed within the ``try`` statement
      :param except_: Function to execute when an :class:`Exception` occurs.
                      It receives a single argument: the exception object.
                      Alternatively, a list of key-value pairs can be passed,
                      mapping exception types to their handler functions.
      :param else_: Function to execute when ``block`` completes successfully.
                    Note that it requires ``except_`` to be provided as well
      :param finally_: Function to execute at the end,
                       regardless of whether an exception occurred or not
  
      :return:  If no exception was raised while executing ``block``,
                the result of ``else_`` (if provided) or ``block`` is returned.
                Otherwise, the result of ``except_`` is returned.
  
      Note that :func:`try_` can _still_ raise an exception if it occurs
      while evaluating ``except_``, ``else_`` or ``finally_`` functions.
      """
      ensure_callable(block)
      if not (except_ or else_ or finally_):
          raise TypeError("at least one of `except_`, `else_` or `finally_` "
                          "functions must be provided")
      if else_ and not except_:
          raise TypeError("`else_` can only be provided along with `except_`")
  
      if except_:
          if callable(except_):
              except_ = [(Exception, except_)]
          else:
              ensure_iterable(except_)
              if is_mapping(except_):
                  ensure_ordered_mapping(except_)
                  except_ = except_.items()
  
          def handle_exception():
              """Dispatch current exception to proper handler in ``except_``."""
              exc_type, exc_object = sys.exc_info()[:2]
              for t, handler in except_:
                  if issubclass(exc_type, t):
                      return handler(exc_object)
              raise
  
          if else_:
              ensure_callable(else_)
              if finally_:
                  ensure_callable(finally_)
                  try:
                      block()
                  except:
                      return handle_exception()
                  else:
                      return else_()
                  finally:
                      finally_()
              else:
                  try:
                      block()
                  except:
                      return handle_exception()
                  else:
                      return else_()
          else:
              if finally_:
                  ensure_callable(finally_)
                  try:
                      return block()
                  except:
                      return handle_exception()
                  finally:
                      finally_()
              else:
                  try:
                      return block()
                  except:
                      return handle_exception()
      elif finally_:
          ensure_callable(finally_)
          try:
              return block()
          finally:
              finally_()