On Tue, 2008-04-15 at 13:54 +0800, Penny Y. wrote: > 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:
You need to define the urllib first. url=urllib2 try: r=urllib2.urlopen("http://un-know-n.com/") except url.URLError,e: print str(e) sys.exit(1) print r.info() You can't just launch into a catchable exception without first defining something. --Paul -- ------------------------------------------------------------. | Chisimba PHP5 Framework - http://avoir.uwc.ac.za | :------------------------------------------------------------:
All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
-- http://mail.python.org/mailman/listinfo/python-list