...

/

Applying Keyword Arguments

Applying Keyword Arguments

Learn how partial functions apply keyword arguments. Also, look at scenarios where you can do without partial application.

How to apply keyword arguments

A partial function can apply keyword arguments too. Here is a simple example:

Press + to interact
def make_print(sep):
def f(*args):
return print(*args, sep=sep)
return f
print_csv = make_print(', ')
print_colon = make_print(':')
print_csv(1, 2, 3) # 1, 2, 3
print_colon(1, 2, 3) # 1:2:3

The make_print function returns a partial application of the standard print function with the sep ...

Access this course and 1400+ top-rated courses and projects.