¡@

Home 

python Programming Glossary: my_safe_eval

Using ast and whitelists to make python's eval() safe?

http://stackoverflow.com/questions/12523516/using-ast-and-whitelists-to-make-pythons-eval-safe

raise Exception Unknown function s call.func.id def my_safe_eval s tree ast.parse s mode 'eval' cnv CleansingNodeVisitor cnv.visit.. compile tree s eval return eval compiled SAFE_FX So my_safe_eval '2 4 exp 1.3 ' works while my_safe_eval ' .__class__' tricks.. SAFE_FX So my_safe_eval '2 4 exp 1.3 ' works while my_safe_eval ' .__class__' tricks and my_safe_eval 'open something evil '..