title: Use eval with dictionary without losing imported modules in Python2
body: <p>I have a string to be executed inside my python program and I want to change some variables in the string like x[1], x[2] to something else.
  I had previously used eval with 2 arguments (the second being a dict with replaced_word: new_word) but now I noticed I can't use previously imported modules like this. So if I do this</p>
  
  <pre><code>from math import log
  eval(log(x[1], {x[1]: 1})
  </code></pre>
  
  <p>it will say it doesn't recognize the name log.
  How can I use eval like this without losing the global variables?
  I can't really make sense of the documentation:
  <a href="https://docs.python.org/2/library/functions.html#eval" rel="nofollow">https://docs.python.org/2/library/functions.html#eval</a>
  so an explanation would be useful too.</p>