... lambda: functions


Python functions are much like normal variables.

def double(x):
    return x * 2

def add_one(x):
    return x + 1

I can put these two functions in a list.

function_list = [double, add_one]

These functions have not executed just, but I can keep them around to run later. That's what is happening in this block of code;

number = 1
for func in [add_one, double, add_one]:
    number = func(number)

Make sure that you understand what is happening in this block of code.

Feedback? See an issue? Something unclear? Feel free to mention it here.

If you want to be kept up to date, consider signing up for the newsletter.