def func(): from function import Map print Map.keys() # ['func3', 'func2', 'func1'] print Map.values() # [<function <lambda> at 0x21feed8>, <function <lambda> at 0x21fee60>, <function <lambda> at 0x21fede8>] print Map.iteritems() # <dictionary-itemiterator object at 0x226ef18> print Map.viewkeys() # dict_keys(['func3', 'func2', 'func1']) print Map.viewvalues() # dict_values([<function <lambda> at 0x21feed8>, <function <lambda> at 0x21fee60>, <function <lambda> at 0x21fede8>]) print Map.viewitems() # dict_items([('func3', <function <lambda> at 0x21feed8>), ('func2', <function <lambda> at 0x21fee60>), ('func1', <function <lambda> at 0x21fede8>)])
def func(name, x): from function import Map if Map.has_key(name): print Map[name](x) else: print 'It\'s not a valid function name:', name, ', valid function names:', Map.keys() print 'It\'s not a valid function name:' + name + ', valid function names:' + str(Map.keys())