Using functools.partial to Bind Arguments to Functions in Python


Create new functions with some arguments of another function pre-filled.

Source Code

from functools import partial
def multiply(x, y):
    return x * y
double = partial(multiply, 2)
print(double(4))
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments