def range_comparison(op, checks, value, default=None):
        """
        An extensible ternary operator
        Takes an operator such as op.lt
        checks are tuples of sentinel values and results and must be supplied in
        the right order to suit the operator and prevent it matching greedily.
        ie. with lt checks must be in ascending order and descending or for gt
        """
        for sentinel, result in checks:
            if op(value, sentinel):
                return result
        return default

        An extensible ternary operator
        Takes an operator such as op.lt
        checks are tuples of sentinel values and results and must be supplied in
        the right order to suit the operator and prevent it matching greedily.
        ie. with lt checks must be in ascending order and descending or for gt
        
recipes/Python/578158_Range_comparison/recipe-578158.py