Title: Partial Function Applications
Slug: partial_functions_applications
Summary: Partial Functions Applications in Python.
Date: 2016-01-23 12:00
Category: Python
Tags: Basics
Authors: Chris Albon

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


In [5]:
from functools import partial

Create A Function


In [6]:
def multiply(x, y):
    return x * y

Create A Function With Y Pre-Filled


In [7]:
double = partial(multiply, y=2)

Run The Partial Function


In [8]:
double(3)


Out[8]:
6