title: Problem while defining a function in a `for` loop in Python
body: <p>I have the following minimal example that reproduces the issue:</p>
  <pre><code>def f1(a, b):
      print(1)
      return a + b
  
  
  def f2(a, b):
      print(2)
      return a * b
  
  
  funcs = f1, f2
  
  
  _funcs = []
  for func in funcs:
  
      def _func(x):
          return func(*x)
  
      _func.__name__ = func.__name__
      _funcs.append(_func)
  funcs = _funcs
  
  
  for func in funcs:
      print(func([2, 3]))
  </code></pre>
  <p>This throws a <code>TypeErro</code>:</p>
  <blockquote>
  <p>TypeError: _func() takes 1 positional argument but 2 were given</p>
  </blockquote>
  <p>with the following traceback:</p>
  <pre><code>---------------------------------------------------------------------------
  
  TypeError                                 Traceback (most recent call last)
  
  &lt;ipython-input-93-e24e67b5e525&gt; in &lt;module&gt;()
       22 
       23 for func in funcs:
  ---&gt; 24     print(func([2, 3]))
  
  &lt;ipython-input-93-e24e67b5e525&gt; in _func(x)
       14 
       15     def _func(x):
  ---&gt; 16         return func(*x)
       17 
       18     _func.__name__ = func.__name__
  
  TypeError: _func() takes 1 positional argument but 2 were given
  </code></pre>
  <p>I am not sure why as it seems to me that <code>_func()</code> is always called with a single argument.</p>
  <p>I suspect what I want to do would be done with <code>functools</code>, but still I fail to see why the above code works this way. Any hint?</p>