title: Evaluate condition of if in python
body: <p>I have the AST of a python program and want to manually evaluate the condition of an if statement.</p>
  
  <pre><code>cond = node.test
  b = eval(compile(cond,"&lt;string&gt;","eval"))
  print b
  </code></pre>
  
  <p>Where node is the If-Node, gives me <em>TypeError: expected Expression node, got Compare</em>, even if Compare is an expression according to the grammar in the python doc of ast.</p>
  
  <p>Any ideas?</p>