Skip to content Skip to sidebar Skip to footer

Passing Python Function As Argument Without Executing It?

I have this function: def a(one, two, the_argument_function): if one in two: return the_argument_function my the_argument_function looks something like this: def b(do_

Solution 1:

package2.b(do_this, do_that) is a function call (a function name followed by parenthesis). Instead you should be passing only the function name package2.b the function a

You will also need to modify function a such that function be is called when the condition is satisfied

# function a definition defa(one, two, the_argument_function, argument_dict):
    if one in two:
        return the_argument_function(**argument_dict)

defb(do_this, do_that):
    print"hi."# function call for a
a(one, two, b, {'do_this': some_value, 'do_that': some_other_value}) 

Post a Comment for "Passing Python Function As Argument Without Executing It?"