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