title: Using eval securely to execute functions
body: <pre><code>def myFunc(arg1, arg2):
      print "This is a test with " + arg1 + " and " + arg2
  
  while (input != "quit"):
      input = raw_input("&gt; ")
  
      if input != "quit":
          eval(input)
  </code></pre>
  
  <p>This code gives me a prompt, allowing me to invoke <code>myFunc</code> with parameters I want. I know that <code>eval</code> can be dangerous if a dictionary is not supplied, so I added this:</p>
  
  <pre><code>eval(input, {"__builtins__": {} }
  </code></pre>
  
  <p>Now I can no longer invoke <code>myFunc</code>. How do I fix this without leaving <code>eval</code> open to exploits?</p>