def is_sage_rel(f, rel=None):
    """
    sage: assert not is_sage_rel(7.2)
    sage: assert not is_sage_rel(x)
    sage: assert not is_sage_rel(x+7)
    sage: assert is_sage_rel(x==3,operator.eq)

    sage: assert is_sage_rel(x<=3,operator.le)
    sage: assert not is_sage_rel(x<=3,operator.lt)
    sage: assert not is_sage_rel(x+3,operator.lt)

    sage: y = var('y')
    sage: assert is_sage_rel(x+y<=3)
    """

    try:
        if not f.is_relational(): 
            return False

        if rel is None:
            return True
        else:
            return f.operator() == rel

    except AttributeError:
        return False