Skip to content

Instantly share code, notes, and snippets.

@dcolish
Created August 8, 2010 17:10
Show Gist options
  • Save dcolish/514273 to your computer and use it in GitHub Desktop.
Save dcolish/514273 to your computer and use it in GitHub Desktop.
import ast
node = ast.Expression(ast.BinOp(left=ast.Num(5, lineno=0, col_offset=0),
op=ast.Add(),
right=ast.Num(2, lineno=0, col_offset=0),
lineno=0,
col_offset=0),
lineno=0,
col_offset=0)
print eval(compile(ast.parse(node), '<string>', mode='eval'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment