title: How to import modules given a list of their names?
body: <p>I am trying to import modules from a list. This would be to allow easier editing of imported modules, cleaner error message, and better error handling. Here is basically what I am trying to do:</p>
  
  <pre><code>imports = ['sys', 'itertools', 'datetime', 'os']
  for x in imports:
      try:
          import x
          print "Successfully imported ", x, '.'
      except ImportError:
          print "Error importing ", x, '.'
  </code></pre>
  
  <p>The issue here is that it tries importing x, not the value x should hold. I realize that to import from the list I could do something like below, but I do not see a way to handle the errors with it:</p>
  
  <pre><code>imports = ['sys', 'itertools', 'datetime', 'os']
  modules = map(__import__, imports)
  </code></pre>
  
  <p>Is there a way to integrate the error handling with this method or should I try a different approach?</p>