예제 #1
0
def p_any(*predicates):
    """Return a lambda that evaluates to True if ANY the predicates passed are
    truthy.  The predicates can be functions or values.

    :param predicates: a list of callables or values
    :returns: Callable(fn: -> boolean)
    :raises: may raise anything, depending on the callables
    """
    return Callable(lambda: any((_resolve_callable(p) for p in predicates)))
예제 #2
0
def p_not(predicate):
    """Return a lambda that does the NOT of the predicate passed
    The predicate can be a value or a function

    :param predicate: a value or function (FN() -> ?)
    :returns: Callable(fn: -> boolean)
    :raises: may raise anything, depending on the callables
    """
    return Callable(lambda: not _resolve_callable(predicate))
예제 #3
0
 def __le__(self, other):
     return Callable(lambda: not self.__gt__(other)())
예제 #4
0
 def __gt__(self, other):
     assert isinstance(other, str) or isinstance(other, self.__class__)
     if other not in self._list:
         raise KeyError("Item '{}' is not in list '{}'".format(
             other, self._list))
     return Callable(lambda: self.index > self._list.index(other))
예제 #5
0
 def __ne__(self, other):
     return Callable(lambda: not self.__eq__(other)())
예제 #6
0
 def __gt__(self, other):
     return Callable(
         lambda: _resolve_callable(self.item) > _resolve_callable(other))