Чебанова Анастасия, 515гр SafeEval 11906 | Александра Рыбакова, 515 группа SafeEval 11893 | ||||
---|---|---|---|---|---|
n | 1 | def safeval(strg, globls=globals(), locls=locals()): | n | 1 | def safeval(exp, g=globals(), l=locals()): |
2 | try: | 2 | try: | ||
n | 3 | globls = globls.copy() | n | 3 | g = g.copy() |
4 | except: | 4 | except: | ||
5 | pass | 5 | pass | ||
6 | try: | 6 | try: | ||
n | 7 | locls = locls.copy() | n | 7 | l = l.copy() |
8 | except: | 8 | except: | ||
9 | pass | 9 | pass | ||
10 | try: | 10 | try: | ||
n | 11 | return eval(strg, globls, locls) | n | 11 | return eval(exp, g, l) |
12 | except NameError: | 12 | except NameError: | ||
t | 13 | return strg | t | 13 | return exp |
14 | except Exception as E: | 14 | except Exception as e: | ||
15 | return E | 15 | return e |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|