title: How to get exception message in Python properly
body: <p>What is the best way to get exceptions' messages from components of standard library in Python?</p>
  
  <p>I noticed that in some cases you can get it via <code>message</code> field like this:</p>
  
  <pre><code>try:
    pass
  except Exception as ex:
    print(ex.message)
  </code></pre>
  
  <p>but in some cases (for example, in case of socket errors) you have to do something like this:</p>
  
  <pre><code>try:
    pass
  except socket.error as ex:
    print(ex)
  </code></pre>
  
  <p>I wondered is there any standard way to cover most of these situations?</p>