[docs] Issue in urllib2 doc for python 3.0 to 3.?
senthil at uthcode.com
Wed Jun 25 23:08:48 CEST 2014
The tutorial mentions about Exception hierarchy and URLError catches
HTTPError exception too.
Once that is caught as e, you can refer to the attributes e.code and
So the current example is good as it is.
On Mon, Jun 23, 2014 at 9:21 AM, Adrix Remi <electro.adrix at gmail.com> wrote:
> response = urlopen(req)
> except URLError as e:
> if hasattr(e, 'code'):
> print('The server couldn\'t fulfill the request.') # HTTPError
> print('Error code: ', e.code)
> elif hasattr(e, 'reason'):
> print('We failed to reach a server.') # URLError handling
> print('Reason: ', e.reason)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the docs