Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Pass arbitrary number of functions

  • As an advanced example we could even pass an arbitrary number of functions

def run_these(value, *functions):
    print(functions)
    for func in functions:
        print(func(value))

run_these("abc", len, lambda x: x+x,  lambda y: f"text: {y}")

Output:

(<built-in function len>, <function <lambda> at 0x7fcb4e8bedc0>, <function <lambda> at 0x7fcb4e8bee50>)
3
abcabc
text: abc