【Python】实现partial

  • Post author:
  • Post category:python


def add(a, b):
    return a + b


def partial(func, *args1, **kwargs1):
    def new_func(*args2, **kwargs2):
        return func(*args1, *args2, **kwargs1, **kwargs2)

    return new_func


add_1 = partial(add, 1)

print(add_1(2))



版权声明:本文为qq_44647926原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。