import operator


def str_to_operator(s):
    """
    Turns a string into the corresponding operator.

    Examples
    --------
    >>> str_to_operator("<")(1, 2)  # equivalent to '1 < 2'
    True
    """
    return {
        # https://docs.python.org/3/library/operator.html#mapping-operators-to-functions
        "<": operator.lt,
        "<=": operator.le,
        "==": operator.eq,
        "!=": operator.ne,
        ">=": operator.ge,
        ">": operator.gt,
    }[s]