title: Python using getattr to call function with variable parameters
body: <p>I'm using getattr to call different functions depending on a variable.</p>
  
  <p>Im doing something like that:</p>
  
  <pre><code>getattr(foo, bar) ()
  </code></pre>
  
  <p>That works, calling functions like foo.bar()</p>
  
  <p>My problem is that I have 'bar' functions and I want to call it with different parameters. For example:</p>
  
  <pre><code>def f1() :
    pass
  
  def f2(param1) :
    pass
  
  def f3(param1,param2) :
    pass
  </code></pre>
  
  <p>so 'bar' could be f1, f2, or f3</p>
  
  <p>I tried this:
  assumming that params is a list which contains all parameters needed for the 'bar' function</p>
  
  <pre><code>getattr(foo, bar) (for p in params :)
  </code></pre>
  
  <p>I watching for a "clean" solution, with no needed to watch the length on the params variable</p>