Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 20b50b1

Browse files
author
Michael Foord
committed
Examples correction in urllib2 howto. Michael Foord
1 parent da31a3f commit 20b50b1

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

Doc/howto/urllib2.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ e.g. ::
204204

205205
>>> req = urllib.request.Request('http://www.pretend_server.org')
206206
>>> try: urllib.request.urlopen(req)
207-
>>> except urllib.error.URLError, e:
207+
>>> except urllib.error.URLError as e:
208208
>>> print(e.reason)
209209
>>>
210210
(4, 'getaddrinfo failed')
@@ -313,7 +313,7 @@ geturl, and info, methods as returned by the ``urllib.response`` module::
313313
>>> req = urllib.request.Request('http://www.python.org/fish.html')
314314
>>> try:
315315
>>> urllib.request.urlopen(req)
316-
>>> except urllib.error.URLError, e:
316+
>>> except urllib.error.URLError as e:
317317
>>> print(e.code)
318318
>>> print(e.read())
319319
>>>
@@ -342,10 +342,10 @@ Number 1
342342
req = Request(someurl)
343343
try:
344344
response = urlopen(req)
345-
except HTTPError, e:
345+
except HTTPError as e:
346346
print('The server couldn\'t fulfill the request.')
347347
print('Error code: ', e.code)
348-
except URLError, e:
348+
except URLError as e:
349349
print('We failed to reach a server.')
350350
print('Reason: ', e.reason)
351351
else:
@@ -367,7 +367,7 @@ Number 2
367367
req = Request(someurl)
368368
try:
369369
response = urlopen(req)
370-
except URLError, e:
370+
except URLError as e:
371371
if hasattr(e, 'reason'):
372372
print('We failed to reach a server.')
373373
print('Reason: ', e.reason)

0 commit comments

Comments
 (0)