Enable support for math functions, such as cos, acos etc..
This could be achieved by using exec instead of eval, enabling the user to type alpha numeric characters in to the input text. The problem will be that this will allow the user to type any valid python code, witch dangerous...
To avoid this code execution it is possible to first parse the input code into an AST using the ast builtin python module (ref https://docs.python.org/3/library/ast.html). Then, scan each Call Node, allowing only those present on the math module...
Expanding this idea, maybe it's possible to allow the use store variables inside an controlled scope and add suport to lambdas!
This sounds like something that could be done easily enough! I think that it's possible to change the scope of exec() so users could write python code, but disallow them access to system functions
Enable support for math functions, such as
cos
,acos
etc..This could be achieved by using
exec
instead ofeval
, enabling the user to type alpha numeric characters in to the input text. The problem will be that this will allow the user to type any valid python code, witch dangerous... To avoid this code execution it is possible to first parse the input code into an AST using theast
builtin python module (ref https://docs.python.org/3/library/ast.html). Then, scan each Call Node, allowing only those present on themath
module...Expanding this idea, maybe it's possible to allow the use store variables inside an controlled scope and add suport to lambdas!