New submission from Tim Morris <timo...@morrises.org.uk>:

In the HOWTO for urllib2 for Python 2, in the Handling Exceptions section, it 
discusses the URLError exception being raised by urlopen() 
(https://docs.python.org/2/howto/urllib2.html#urlerror). The code snippet 
example for this has (I think) a minor error:
the 3rd line reads:
"except URLError as e:"
which I think should be:
"except urllib2.URLError as e:"

The code as given only works if urllib2 had been imported via:
"from urllib2 import *"
The snippet doesn't list the import statements but all the other examples just 
use "import urllib2" (and obviously "from x import *" is bad practice anyway 
and wouldn't be encouraged or expected).

I am relatively new to Python, so it's possible it *is* correct and I just 
implemented it incorrectly. But if not, it would be helpful to correct it (even 
though it's a very minor error) so that other newbies like me don't come 
unstuck when using the tutorial.

----------
assignee: docs@python
components: Documentation
messages: 310201
nosy: MarmiteFox, docs@python
priority: normal
severity: normal
status: open
title: urllib2 HOWTO URLError example minor error
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32586>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to