title: Python: using eval to execute code in the string
body: <p>I have a syntax tree</p>
  
  <pre><code>Tree(if, [Tree(condition, [Token(VARIABLE, 'age'), Token(ACTION_OPERATOR, '&gt;'), Token(SIGNED_NUMBER, '18')]), Tree(result, [Tree(if, [Tree(condition, [Token(VARIABLE, 'salary'), Token(ACTION_OPERATOR, '&gt;'), Token(SIGNED_NUMBER, '100000')]), Tree(result, [Token(STRING, 'success')]), Tree(condition, [Token(VARIABLE, 'salary'), Token(ACTION_OPERATOR, '&lt;'), Token(SIGNED_NUMBER, '50000')]), Tree(result, [Token(STRING, 'fail')]), Tree(else, [Token(STRING, 'get_more_info')])])]), Tree(else, [Token(STRING, 'fail')])])
  </code></pre>
  
  <p>And I convert it to string:</p>
  
  <pre><code>if age &gt; 18:
      if salary &gt; 100000:
          print('success')
      elif salary &lt; 50000:
          print('fail')
      else: 
          print('get_more_info')
  else:
      print('fail')
  </code></pre>
  
  <p>I declare variables:</p>
  
  <pre><code>age = 20
  salary = 60000
  </code></pre>
  
  <p>And try to execute this code with</p>
  
  <pre><code>eval(code)
  </code></pre>
  
  <p>and get an error</p>
  
  <pre><code>File "&lt;string&gt;", line 1
  if age &gt; 18: 
   ^
  SyntaxError: invalid syntax
  </code></pre>