<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _dispatch(self, typ):
 """ returns the appropriate handler, for the object passed. """

        for can_handle, handler in self._handler_pairs:
            # can handle could raise an exception here
            # such as issubclass being called on an instance.
            # it's easier to just ignore that case.
            try:
                if can_handle(typ):
                    return handler
            except Exception:
                pass
        raise KeyError("unable to find handler for {0}".format(typ))