title: Run code inside a string with python .format
body: <p>I need to use code saved in a string (tmp_str) inside .format ?</p>
  <pre><code>tmp_str=&quot;ID='ID_VAR_DICT'&quot;
      
  sql_text=&quot;SELECT FIELD FROM TABLE_A WHERE ID = {ID}&quot;
  sql_query = sql_text.format(ID='ID_VAR_DICT')
  print ('sql_query --&gt;',sql_query) #Print A
      
  sql_query = sql_text.format(eval(tmp_str))
  print ('sql_query --&gt;',sql_query) #Print B
  </code></pre>
  <p>Basically I need #Print B to output the same as #Print A but passing the contents off tmp_str to .format</p>
  <p>Output:</p>
  <pre><code>('sql_query --&gt;', 'SELECT FIELD FROM TABLE_A WHERE ID = ID_VAR_DICT')
  Traceback (most recent call last):
    File &quot;_testes.py&quot;, line 7, in &lt;module&gt;      
      sql_query = sql_text.format(eval(tmp_str))
    File &quot;&lt;string&gt;&quot;, line 1
      ID='ID_VAR_DICT'
  </code></pre>
  <p>Thanks in advance,
  M</p>