Is it possible to pass functions with arguments to another function in Python?
Say for something like:
def perform(function): return function()
But the functions to be passed will have arguments like:
action1() action2(p) action3(p,r)
Do you mean this?
def perform( fun, *args ): fun( *args ) def action1( args ): something def action2( args ): something perform( action1 ) perform( action2, p ) perform( action3, p, r )
This is what lambda is for:
def Perform(f): f() Perform(lambda: Action1()) Perform(lambda: Action2(p)) Perform(lambda: Action3(p, r))