Skip to content
loading...

re: Is there a way to pass an object to ast.literal_eval to give it variables? VIEW POST

TOP OF THREAD FULL DISCUSSION
re: What I mean, is ast.literal_eval is meant to be a safe version of eval right? Well, take eval, and be able to pass it to it, similar to this: Pyth...
 

So the problem with literal_eval is that it only supports literals. Literals are things like writing a number, string, lists or tuples using their respective syntax. However, you are correct in eval being very unsafe.

I found this project which might be useful or work as inspiration, as it is MIT licensed: github.com/danthedeckie/simpleeval

code of conduct - report abuse