Шагов Виталий 521 SafeEval 12396 | Руслан Касимов, 524 группа SafeEval 12412 | ||||
---|---|---|---|---|---|
n | 1 | def safeval(kek, globs=globals(), locs=None): | n | 1 | def safeval(st, g=globals(), l=None): |
2 | if type(globs) == dict: | 2 | if type(g) is dict: | ||
3 | globs = globs.copy() | 3 | g = g.copy() | ||
4 | try: | 4 | try: | ||
n | 5 | return eval(kek, globs) | n | 5 | return eval(st, g) |
6 | except NameError: | 6 | except NameError: | ||
t | 7 | return kek | t | 7 | return st |
8 | except Exception as e: | 8 | except Exception as e: | ||
9 | return e | 9 | return e |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|