summaryrefslogtreecommitdiffstats
path: root/Doc/howto/urllib2.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/howto/urllib2.rst')
-rw-r--r--Doc/howto/urllib2.rst10
1 files changed, 5 insertions, 5 deletions
diff --git a/Doc/howto/urllib2.rst b/Doc/howto/urllib2.rst
index 69ce508..858c9b1 100644
--- a/Doc/howto/urllib2.rst
+++ b/Doc/howto/urllib2.rst
@@ -214,7 +214,7 @@ e.g. ::
>>> req = urllib2.Request('http://www.pretend_server.org')
>>> try: urllib2.urlopen(req)
- >>> except URLError, e:
+ >>> except URLError as e:
>>> print e.reason
>>>
(4, 'getaddrinfo failed')
@@ -326,7 +326,7 @@ attribute, it also has read, geturl, and info, methods. ::
>>> req = urllib2.Request('http://www.python.org/fish.html')
>>> try:
>>> urllib2.urlopen(req)
- >>> except URLError, e:
+ >>> except URLError as e:
>>> print e.code
>>> print e.read()
>>>
@@ -354,10 +354,10 @@ Number 1
req = Request(someurl)
try:
response = urlopen(req)
- except HTTPError, e:
+ except HTTPError as e:
print 'The server couldn\'t fulfill the request.'
print 'Error code: ', e.code
- except URLError, e:
+ except URLError as e:
print 'We failed to reach a server.'
print 'Reason: ', e.reason
else:
@@ -378,7 +378,7 @@ Number 2
req = Request(someurl)
try:
response = urlopen(req)
- except URLError, e:
+ except URLError as e:
if hasattr(e, 'reason'):
print 'We failed to reach a server.'
print 'Reason: ', e.reason