title: How to conditionally import and run a method from another Python package?
body: <p>I have a project that contains several test suites. I want to be able to specify which suite I'd like to run in the command line:</p>
  
  <pre><code>suite=multiplication python3 .
  </code></pre>
  
  <p>Here's my current file structure:</p>
  
  <pre><code>__main__.py
  suites/
      __init__.py
      addition.py
      subtraction.py
      multiplication.py
      division.py
  </code></pre>
  
  <p><strong>suites/__init__.py</strong></p>
  
  <pre><code>__all__ = ['addition', 'subtraction', 'multiplication', 'division']
  </code></pre>
  
  <p><strong>subtraction.py</strong></p>
  
  <pre><code>def testSuite():
      # Bunch of tests
  </code></pre>
  
  <p><strong>__main__.py</strong></p>
  
  <pre><code>import os
  import suites
  
  # Get suite name from 'suite=xxx' in command line
  suiteName = os.getenv('suite')
  # Based on suiteName, load the correct file
  suite = suites[suiteName]
  # Call the suite loaded from the file
  suite()
  </code></pre>
  
  <p>This errors out:</p>
  
  <pre><code>suite = suites[suiteName]
  TypeError: 'module' object is not subscriptable
  </code></pre>
  
  <p>What's the best way to conditionally import and run a script from another package?</p>