v Partial Function Applications - Python

Partial Function Applications

Partial function application allows us to create "functions" from other functions with pre-filled arguments. This can be very useful when we want to pipe the output of one function into a function requiring two functions.

Preliminaries

from functools import partial

Create A Function

def multiply(x, y):
    return x * y

Create A Function With Y Pre-Filled

double = partial(multiply, y=2)

Run The Partial Function

double(3)
6