a name error

Penny Y. pylists at arcor.de
Tue Apr 15 01:54:43 EDT 2008


Hello,

I run this small script:

import urllib2,sys
try:
    r=urllib2.urlopen("http://un-know-n.com/")
except URLError,e:
    print str(e)
    sys.exit(1)

print r.info()


But got the errors:

Traceback (most recent call last):
  File "t1.py", line 4, in ?
    except URLError,e:
NameError: name 'URLError' is not defined


Why these is not the name of URLError? I saw it on this module's page:

http://www.python.org/doc/lib/module-urllib2.html

Thanks.




More information about the Python-list mailing list