title: List defining the list of variable of function in Python
body: <p>I want to have a function <code>foo</code>  which outputs another function, whose list of variables depends on an input list.</p>
  
  <p>Precisely:</p>
  
  <p>Suppose <code>func</code> is a function with the free variable <code>t</code> and three parameters <code>A,gamma,x</code></p>
  
  <p>Example: <code>func = lambda t,A,gamma,x: Somefunction</code></p>
  
  <p>I want to define a function <code>foo</code>, which takes as input a list and outputs another function. The output function is a sum of <code>func</code>'s, where each <code>func</code> summand has his parameters independent from each other.</p>
  
  <p>Depending on the input list the variables of the outputs changes in the following:</p>
  
  <p>If the entry of the list is 'None' then the output function 'gains' a variable and if the entry of the list is a float it 'fixes' the parameter.</p>
  
  <p>Example:</p>
  
  <pre><code>li=[None,None,0.1]
  g=foo(li)
  </code></pre>
  
  <p>gives the same output as</p>
  
  <p><code>g = lambda t,A,gamma: func(t,A,gamma,0.1)</code> </p>
  
  <p>or</p>
  
  <pre><code>li=[None,None,0.1,None,0.2,0.3]
  g=foo(li)
  </code></pre>
  
  <p>gives the same output as</p>
  
  <p><code>g = lambda t,A1,gamma1,A2:func(t,A,gamma,0.1)+func(t,A2,0.2,0.3)</code></p>
  
  <p>Note: the order in the list is relevant and this behaviour is wanted.</p>
  
  <p>I don't have any clue on how to do that...</p>
  
  <p>I first tried to build a string, which depends on the inout list and then to execute it, but this is surely not the way.</p>