[Python-checkins] r72584 - python/branches/py3k/Doc/howto/urllib2.rst
michael.foord
python-checkins at python.org
Tue May 12 13:19:14 CEST 2009
Author: michael.foord
Date: Tue May 12 13:19:14 2009
New Revision: 72584
Log:
Examples correction in urllib2 howto. Michael Foord
Modified:
python/branches/py3k/Doc/howto/urllib2.rst
Modified: python/branches/py3k/Doc/howto/urllib2.rst
==============================================================================
--- python/branches/py3k/Doc/howto/urllib2.rst (original)
+++ python/branches/py3k/Doc/howto/urllib2.rst Tue May 12 13:19:14 2009
@@ -204,7 +204,7 @@
>>> req = urllib.request.Request('http://www.pretend_server.org')
>>> try: urllib.request.urlopen(req)
- >>> except urllib.error.URLError, e:
+ >>> except urllib.error.URLError as e:
>>> print(e.reason)
>>>
(4, 'getaddrinfo failed')
@@ -313,7 +313,7 @@
>>> req = urllib.request.Request('http://www.python.org/fish.html')
>>> try:
>>> urllib.request.urlopen(req)
- >>> except urllib.error.URLError, e:
+ >>> except urllib.error.URLError as e:
>>> print(e.code)
>>> print(e.read())
>>>
@@ -342,10 +342,10 @@
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:
@@ -367,7 +367,7 @@
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)
More information about the Python-checkins
mailing list