title: Python - call function with arguments based on dictionary lookup
body: <p>I have a bunch of functions that generate some sort of test data and I would like to call them based on a probability distribution I specify.</p>
  
  <pre><code>import numpy as np
  def one():
      print('one')
  
  def two():
      print('two')
  
  def three():
      print('three')
  
  def four():
      print('four')
  
  def five():
      print('five')
  
  funcs = {
      1: one, 2: two, 3: three, 4: four, 5: five
  }
  distribution = [0.1, 0.15, 0.15, 0.2, 0.4]
  my_keys = list(funcs.keys())
  choice = np.random.choice(my_keys, 1, p=distribution)[0]
  funcs[choice]()
  </code></pre>
  
  <p>This picks a key from <code>funcs</code> according to the distribution specified and then executes the corresponding function, and this works as-is. </p>
  
  <p>Now the problem is that each function has a different set of arguments. For example, the function <code>one()</code> could have an argument that makes it have to be called as <code>one(foo)</code> while <code>two</code> needs to be called as <code>two(blah)</code> and so on.</p>
  
  <p>How can I accomplish this? I would rather not go the route of having <code>np.random.choice</code> return a key and then I use an if-then-else construct to call the functions with the correct parameters as that seems pretty un-pythonic.</p>
  
  <p>TIA.</p>