summaryrefslogtreecommitdiffstats
path: root/Doc/howto/urllib2.rst
diff options
context:
space:
mode:
authorMichael Foord <fuzzyman@voidspace.org.uk>2009-05-12 11:19:14 (GMT)
committerMichael Foord <fuzzyman@voidspace.org.uk>2009-05-12 11:19:14 (GMT)
commit20b50b1984a9ee8a19d1e394735d502798e417bc (patch)
tree4b1067f9b9f0c3097c6cc71f2712dd91893f187e /Doc/howto/urllib2.rst
parentda31a3f0c2303796ece492e1bdcd4fe2e4c21953 (diff)
downloadcpython-20b50b1984a9ee8a19d1e394735d502798e417bc.zip
cpython-20b50b1984a9ee8a19d1e394735d502798e417bc.tar.gz
cpython-20b50b1984a9ee8a19d1e394735d502798e417bc.tar.bz2
Examples correction in urllib2 howto. Michael Foord
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 e57f9e5..dfa6d0e 100644
--- a/Doc/howto/urllib2.rst
+++ b/Doc/howto/urllib2.rst
@@ -204,7 +204,7 @@ e.g. ::
>>> 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 @@ geturl, and info, methods as returned by the ``urllib.response`` module::
>>> 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 @@ 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:
@@ -367,7 +367,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)