title: TypeError: eval() arg 1 must be a string, bytes or code object
body: <p>I'm trying to evaluate a function at x0</p>
  
  <pre><code>f = lambda x:mu*div2d(grad2d(x))+x-b
  </code></pre>
  
  <p>I tried this:</p>
  
  <pre><code>def feval(f, *args):
      return eval(f)(*args)
  feval(f,x0)
  </code></pre>
  
  <p>but it throws up a traceback:</p>
  
  <pre><code>Traceback (most recent call last):
  
    File "&lt;ipython-input-128-6be96feb06d6&gt;", line 1, in &lt;module&gt;
      feval(f,x0)
  
    File "&lt;ipython-input-126-67b053764219&gt;", line 2, in feval
      return eval(f)(*args)
  
  TypeError: eval() arg 1 must be a string, bytes or code object
  </code></pre>
  
  <p>I also read that using eval() is bad practice. What'd be a good way to do this then? Thanks. </p>