title: Pythonic way to handle import errors
body: <p>I am using a custom logging module in my project. If it is not available, I'd like to substitute it with a dummy instead of raising an <code>ImportError</code>.</p>
  
  <p>Here's the code which currently does that:</p>
  
  <pre><code>try:
      import logger
  except ImportError:
      print 'Couldn\'t load logger'
  
      class DummyLogger(object):
          def __init__(self):
              pass
          def log(self, image):
              pass
  
      logger = DummyLogger()
  </code></pre>
  
  <p>I don't think it's an elegant solution. It works, sure, but it ain't nice. Is there a better way?</p>