Creating Python function with partial parameters

This is called currying, or partial application. You can use the built-in functools.partial(). Something like the following would do what you want.

import functools
def add(x,y):
    return x + y

inc2 = functools.partial(add, 2)
print inc2(3)

Leave a Comment