Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news.astraweb.com!border2.a.newsrouter.astraweb.com!multikabel.net!newsfeed10.multikabel.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.020 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'python,': 0.01; 'python': 0.08; 'either.': 0.09; 'subject:error': 0.10; 'users,': 0.13; 'better:': 0.16; 'occur.': 0.16; 'x-mailer:apple mail (2.1084)': 0.16; "doesn't": 0.22; 'correctly.': 0.24; 'specify': 0.24; 'expect': 0.25; 'tried': 0.26; 'print': 0.29; 'recognized': 0.30; 'situations': 0.30; 'error': 0.32; 'does': 0.32; 'anyone': 0.32; "can't": 0.33; 'there': 0.33; 'to:addr:python-list': 0.33; 'recognize': 0.34; 'try:': 0.34; 'thank': 0.35; 'certain': 0.35; 'charset:us-ascii': 0.36; 'skip:" 10': 0.36; 'example,': 0.37; 'statements': 0.37; 'response': 0.37; 'using': 0.37; 'put': 0.37; 'but': 0.37; 'received:org': 0.38; 'too,': 0.38; 'should': 0.38; 'subject:with': 0.39; 'to:addr:python.org': 0.39; 'might': 0.40; 'where': 0.40; 'you.': 0.62; 'subject:... ': 0.84; 'subject:types': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mssm.edu; h=date : from : subject : to : message-id : mime-version : content-type : content-transfer-encoding; s=mail; bh=aMgyDZe878vU5KwppoBBV8okWo/3aIugeTQFFloTU2s=; b=U+O+/v/+0dBz9AWjF/e3mwkoPdNhSPms5nUjLYlQkln7ZRrPS8ePUimqcD6MvpsjaRiu X4gedEB+bZqAJi9zVPmSQ5VffiyixqFl3QSo+eAAjSg8HrcOSCUAG8hD7qxYhuodBFLr lEQuV+FAtLXPgNKvM158pgkGRWZYFwic7jb90iy+4W1zkCLieUUVUxMegW0+UuSBIZbJ tcW27ABuKAPLJm+VPbi8ADnhtdEp9/W5emktz/wky6H+pCuxN5Z1tAzI/Fhix0EfOxlm 57z7q0hiR42wmEnsc/2gFw++9/7Eli8wPsOqtvDd4J14pUaHj1HBPMxX3Kdx8Om8UErb 2g== Date: Fri, 19 Aug 2011 15:09:12 -0400 From: Yingjie Lin Subject: try... except with unknown error types To: python-list@python.org MIME-version: 1.0 X-Mailer: Apple Mail (2.1084) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.4.6813, 1.0.211, 0.0.0000 definitions=2011-08-19_07:2011-08-19, 2011-08-19, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=1 spamscore=1 ipscore=0 suspectscore=1 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=6.0.2-1012030000 definitions=main-1108190209 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1313780957 news.xs4all.nl 23915 [2001:888:2000:d::a6]:47858 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:11865 Hi Python users, I have been using try...except statements in the situations where I can expect a certain type of errors might occur. But sometimes I don't exactly know the possible error types, or sometimes I just can't "spell" the error types correctly. For example, try: response = urlopen(urljoin(uri1, uri2)) except urllib2.HTTPError: print "URL does not exist!" Though "urllib2.HTTPError" is the error type reported by Python, Python doesn't recognize it as an error type name. I tried using "HTTPError" alone too, but that's not recognized either. Does anyone know what error type I should put after the except statement? or even better: is there a way not to specify the error types? Thank you. - Yingjie