+ 2
What is the best method for executing expressions entered by the user?
Good morning people. I'm working on a project where the user can set some values for certain variables and use them in a custom expression. There will be fields where he should enter the values and a field to enter the expression, so I need it to set the values separately. I would like to know the best method for executing the expression so that I can include the user-defined values. Should I use exec() or eval()? Is there a more practical way?
2 Answers
+ 2
I donât think you can get any more practical than exec() or eval(). But you can get more customized and/or robust, I think.
Take a look at this:
https://www.sololearn.com/learn/704/
With Python:
https://code.sololearn.com/cUEVZ6d8Z57P/?ref=app
+ 2
Thank you very much, I'll try something like that. o/