title: Calling Different Functions in Python Based on Values in a List
body: <p>I have a script that takes a list of metrics as an input, and then fetches those metrics from the database to perform various operations with them.  </p>
  
  <p>My problem is that different clients get different subsets of the metrics, but I don't want to write a new IF block every time we add a new client. So right now, I have a large IF block that calls different functions based on whether the corresponding metric is in the list. What is the most elegant or <em>Pythonic</em> way of handling this?</p>
  
  <p>Setup and function definitions:</p>
  
  <pre><code>clientOne = ['churn','penetration','bounce']
  clientTwo = ['engagement','bounce']
  
  def calcChurn(clientId):
      churn = cursor.execute(sql to get churn)
      [...]
      return churn
  
  def calcEngagement(clientId):
      engagement = cursor.execute(sql to get engagement)
      [...]
      return engagement
  </code></pre>
  
  <p>Imagine three other functions in a similar format, so there is one function that corresponds to each unique metric.  Now here is the block of code in the script that takes the list of metrics:</p>
  
  <pre><code>def scriptName(client, clientId):
      if churn in client:
          churn = calcChurn(clientId)
      if engagement in client:
          engagement = calcEngagement(clientId)
      if penetration in client:
      [...]
  </code></pre>