title: Convert symbolic expressions to Python functions using SymPy
body: <p>I have a rather large symbolic function that is evaluated for different values of a parameter in a loop. In each iteration, after finding the expression of the function, partial derivatives are derived. Something like this:</p>
  
  <pre><code>from sympy import diff, symbols,exp
  
  def lagrange_eqs(a):
      x,y,z= symbols('x y z')
      FUNC=x**2-2*x*y**2+z+a*exp(z)
      d_lgrng_1=diff(FUNC,x)
      d_lgrng_2=diff(FUNC,y)
      d_lgrng_3=diff(FUNC,z)
      return [d_lgrng_1,d_lgrng_2,d_lgrng_3]
  </code></pre>
  
  <p>Next, I need to convert the output of this function to a Python function so that I can use <code>fsolve</code> to find x, y, z values for which derivatives are zero. The function must take x,y,z as a list. </p>
  
  <p>Now here is my problem: how do I convert the output of the above function to a Python function which could be passed on to a solver. Such a function should look like this (for a=3): </p>
  
  <pre><code>def lagrange_eqs_solve(X): 
      x,y,z=X
      return [2*x - 2*y**2, -4*x*y, 3*exp(z) + 1]
  </code></pre>
  
  <p>I simply copied the output of the first function to build the second one. Is there a way I could code it? (Matlab has a built-in function for this, called matlabFunction) </p>