How to Catch 2 Exceptions at once?

Gregory Piñero gregpinero at
Sun Oct 1 04:09:19 CEST 2006

On 9/30/06, Steve Holden <steve at> wrote:
> As usual, by adding an additional name after the exception specification:
>          try:
>              self.gses =
>          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.

Thanks Steve!

I'll think about the two exceptions at once thing.  Sounds like a challenge ;-)


More information about the Python-list mailing list