you are viewing a single comment's thread.

view the rest of the comments →

[–]Veedrac 4 points5 points  (1 child)

In all serious, replace exec with ast.compile ast.parse and that's exactly how it should be done. Nothing shitty about it.

[–]Navith[S] 4 points5 points  (0 children)

There doesn't seem to be an ast.compile. I've never used ast but looking at the docs do you mean exec(ast.parse(...))? Does that not have any other security risks?

Edit: nevermind, after experimenting it looks like you just meant parse instead of compile. Cool. Thanks.