How to Catch 2 Exceptions at once?
gregpinero at gmail.com
Sun Oct 1 04:09:19 CEST 2006
On 9/30/06, Steve Holden <steve at holdenweb.com> wrote:
> As usual, by adding an additional name after the exception specification:
> self.gses = opener.open(req)
> except (urllib2.HTTPError,urllib2.URLError), exdata:
> do something with exdata ...
> Pedantically speaking, of course, you aren't catching two exceptions at
> once because they don't occur simultaneously: you are writing a
> statement that catches either of two exceptions.
I'll think about the two exceptions at once thing. Sounds like a challenge ;-)
More information about the Python-list