title: Using a partially evaluated function as an argument of another function
body: <p>I have two functions which I wish to compose. The first function depends on 3 variables: <code>X</code>, <code>Y</code>, and <code>Alist</code>. The second function depends on the first function and some other variables. When I try to pass in the first function, I want to also pass in <code>mu</code> and <code>Alist</code>. Is this possible? Here is my actual code:</p>
  <pre><code>def primal_step(X, mu, primal_size, primal_map, primal_prox, nabf, linopT):
      u = primal_map(X) - primal_size * (nabf(X) + linopT(mu))
      return primal_prox(primal_size, u)
  
  def gradf(X, Y, Alist):
      grad = np.zeros(X.shape)
      for i in range(X.shape[0]):
          A = Alist[i]
          for j in range(X.shape[1]):
              for p in range(A.shape[0]):
                  grad[i, j] += A[p,j] * np.log(np.dot(A[p], X[i])/Y[i][p])
      return grad
  </code></pre>
  <p>I want to evaluate <code>primal_step</code> with <code>nabf</code> equal to <code>gradf( __ , Y, Alist)</code>, i.e. <code>Y</code> and <code>Alist</code> are supplied before passing <code>gradf</code> into <code>primal_step</code>.</p>
  <p>Edit:</p>
  <p>What I currently do is the following,</p>
  <pre><code>def gradf2(X):
      return gradf(X, Y, Alist)
  </code></pre>
  <p>which seems to work but I wonder if there's a better way to do it?</p>