root/lib/eval_.py @ 8051
1 | 1866 | aaronmk | # Code evaluation from strings
|
---|---|---|---|
2 | |||
3 | import sys |
||
4 | |||
5 | def func2name(func): return (func.__module__, func.__name__) |
||
6 | |||
7 | def name2func(module_name, func_name): |
||
8 | return getattr(__import__(module_name), func_name) |
||
9 | |||
10 | def call_by_name(module_name, func_name, args, kw_args): |
||
11 | return name2func(module_name, func_name)(*args, **kw_args) |