functional.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:thorn 作者: robinhood 项目源码 文件源码
def wrap_transition(op, did_change):
    """Transform operator into a transition operator.

    That is, an operator that
    only returns true if the ``did_change`` operator also returns true.

    Note:
        E.g. ``wrap_transition(operator.eq, operator.ne)`` returns function
        with signature ``(new_value, needle, old_value)`` and only returns
        true if new_value is equal to needle, but old_value was not equal
        to needle.
    """
    def compare(new_value, needle, old_value):
        return did_change(old_value, needle) and op(new_value, needle)

    return compare
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号