The error is due to the fact that function names are not a string that you cannot call, for example, 'func1'() it should be func1() ,
You can do this:
{ 'func1': func1, 'func2': func2, 'func3': func3, }.get(choice)()
it by mapping a string to function references
side note : you can write a default function, for example:
def notAfun(): print "not a valid function name"
and improve your code as follows:
{ 'func1': func1, 'func2': func2, 'func3': func3, }.get(choice, notAfun)()
source share