How to Catch 2 Exceptions at once?

James Stroud jstroud at mbi.ucla.edu
Sat Sep 30 22:11:41 EDT 2006


Gregory Piñero wrote:
> How can I catch 2 exceptions at once for example:
> 
>        try:
>            self.gses = opener.open(req)
>        except (urllib2.HTTPError,urllib2.URLError):
>            do something..
> 
> Seems to work, but how do I also get information about the error?
> 
py> try:
...   raise ValueError, 'Illegal value for your shoe size!'
... except (IndexError, ValueError), e:
...   print e
...
Illegal value for your shoe size!


-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/



More information about the Python-list mailing list