title: NameError: global name 'HTTPError' is not defined
body: <p>I have a command in a try clause which I know throws an exception.  I'm trying to catch it in an "except" clause, but the except clause seems to not recognize the existence of the exception. The exception, when unhandled (i.e. not enclosed in a try clause), looks like this in the interactive window:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;console&gt;", line 1, in &lt;module&gt;
    File "C:\Users\Andy\software\Turkeys\actions.py", line 234, in annotate
      annotation=annotator.ncbo_annotate(thing)
    File "C:\Users\Andy\software\Turkeys\annotator.py", line 49, in ncbo_annotate
      fh = urllib2.urlopen(submitUrl, postData)
    File "C:\32Python27\lib\urllib2.py", line 126, in urlopen
      return _opener.open(url, data, timeout)
    File "C:\32Python27\lib\urllib2.py", line 406, in open
      response = meth(req, response)
    File "C:\32Python27\lib\urllib2.py", line 519, in http_response
      'http', request, response, code, msg, hdrs)
    File "C:\32Python27\lib\urllib2.py", line 444, in error
      return self._call_chain(*args)
    File "C:\32Python27\lib\urllib2.py", line 378, in _call_chain
      result = func(*args)
    File "C:\32Python27\lib\urllib2.py", line 527, in http_error_default
      raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
  HTTPError: HTTP Error 500: Internal Server Error
  </code></pre>
  
  <p>The when I put the command in a try/except construct in the first file in that list, "actions.py", like this:</p>
  
  <pre><code>try:
      annotation=annotator.ncbo_annotate(thing)
  except HTTPError: 
      ...do some things with this 
  </code></pre>
  
  <p>I would expect that the above clause would catch the "HTTPError: HTTP Error 500: Internal Server Error" being produced when I run the ncbo_annotate function, but instead when I run the above, I am getting an error saying global name "HTTPError" is not defined:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;console&gt;", line 1, in &lt;module&gt;
    File "C:\Users\Andy\software\Turkeys\actions.py", line 235, in annotate
      except HTTPError:
  NameError: global name 'HTTPError' is not defined
  </code></pre>
  
  <p>So what's the deal?  I thought python raises the exception until it finds a handler within a try clause or spits it out unhandled.  Why does my code not have any idea what an HTTPError is, or alternatively, how do I tell it what it is so that it can handle it? </p>