title: How can i get python function object from a string
body: <p>I have python functions in string format and I want to get the python objects of these functions in the scope of the program. I have tried <code>exec()</code>, <code>eval()</code> and <code>ast.literal_eval()</code> but none of these return a function object.</p>
  
  <p>For example:</p>
  
  <pre><code>s = "def add(args):\n    try:\n        return sum([int(x) for x in args])\n    except Exception as e:\n        return 'error'\n
  </code></pre>
  
  <p>this is a simple function in string to add elements of a list. I am looking for a module of utility which can return the object of the function <code>add</code></p>
  
  <pre><code>function_obj = some_function(s)
  print 'type:', type(function_obj)
  type: &lt;type 'function'&gt;
  </code></pre>