title: Calling functions with parameters using a dictionary in Python
body: <p>I'm making a program which has a main menu that asks the user to input an option and store it in integer <code>option1</code>, which is looked up in dictionary <code>options</code>. The corresponding function is then run. The following code works if the functions have no parameters:</p>
  
  <pre><code>options = {0 : FunctionZero,    # Assign functions to the dictionary
              1 : FunctionOne,
              2 : FunctionTwo,
              3 : FunctionThree}
  
  options[option1]()    # Call the function
  </code></pre>
  
  <p>If the functions have parameters the above code doesn't work as the <code>()</code> part assumes the functions have no parameters, but I tried the following, which stores the functions' names and parameters in tuples within the dictionary:</p>
  
  <pre><code>options = {0 : (FunctionZero,""),    # FunctionsZero, FunctionOne
              1 : (FunctionOne,""),    # and FunctionTwo have no parameters
              2 : (FunctionTwo,""),
              3 : (FunctionThree,True)}    # FunctionThree has one parameter
  
  if options[option1][1] == "":    # Call the function
      options[option1][0]()
  else:
      options[option1][0](options[option1][1])
  </code></pre>
  
  <p>This code seems to work fine, but I was wondering if there's a better way to do this, especially if the functions require several parameters? In other languages like C# I'd probably use a switch or case statement (which is not in Python) and I'm avoiding using <code>if...elif</code> statements for this.</p>