Logo

Programming-Idioms

History of Idiom 37 > diff from v4 to v5

Edit summary for version 5 by :

Version 4

2015-08-20, 17:18:43

Version 5

2015-08-22, 10:11:15

Idiom #37 Currying

Technique of transforming a function that takes multiple arguments and returning a function for which some of the arguments are preset.

Idiom #37 Currying

Technique of transforming a function that takes multiple arguments and returning a function for which some of the arguments are preset.

Imports
from functools import partial
Code
def f(a, b):
	return a+b

add_to_two = partial(f, 2)
Doc URL
https://docs.python.org/3/library/functools.html#functools.partial