Is there a better way to express the dispatch (switch) code without using a lambda? I think I need the lambda to act as an intermediary because the functions have varying numbers of parameters.
def printf(arg):
print arg
def printf2(arg1, arg2):
print arg1
print arg2
def printn(arg):
print arg
action = 'op2'
functions = {
'op1': lambda: printf('op1 called'),
'op2': lambda: printf2('op2 called', 'param 2'),
}
functions.get(action, lambda: printn('default op'))()