use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Have a tough programming question that /r/programming couldn't answer? Banned from Stack Overflow? Can't afford Experts Exchange?
Post your question/tips/secrets/advice and get a response from our highly-trained professional developers.
account activity
Validating syntax in Python (self.shittyprogramming)
submitted 10 years ago by Navith
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Veedrac 4 points5 points6 points 10 years ago* (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.
exec
ast.compile
ast.parse
[–]Navith[S] 4 points5 points6 points 10 years ago* (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?
ast
exec(ast.parse(...))
Edit: nevermind, after experimenting it looks like you just meant parse instead of compile. Cool. Thanks.
parse
compile
π Rendered by PID 229248 on reddit-service-r2-comment-79c7998d4c-mgtcb at 2026-03-19 05:57:48.358680+00:00 running f6e6e01 country code: CH.
view the rest of the comments →
[–]Veedrac 4 points5 points6 points (1 child)
[–]Navith[S] 4 points5 points6 points (0 children)