Cathing several potential errors?
sjmachin at lexicon.net
Sat Sep 6 18:42:37 EDT 2008
On Sep 7, 8:13 am, cnb <circularf... at yahoo.se> wrote:
> if i do
> except TypeError, IndexError:
> only the first error will get caught. I dont want to use Exception and
> catch all errors, but just 2. how can i do that?
The syntax for what you can have between "except" and ":" is:
[expression ["," target]]
'target' is an optional name to be bound to the actual exception
object that is raised.
If you want to catch multiple kinds of exception, 'expression' needs
to be a tuple.
More information about the Python-list