def __copy_pred(self):
    return copy.copy(self.pred)

def __and__(self, predicate):

    def func(obj):
        return self.pred(obj) and predicate(obj)
return P(func)

def __or__(self, predicate):

    def func(obj):
        return self.pred(obj) or predicate(obj)
return P(func)
Pointfree function combination in Python