Exception Handling in Python

Suchandra Thapa ssthapa at harper.uchicago.edu
Tue Oct 17 02:10:29 EDT 2000


    I'm trying to figure out how to catch an exception, do some 
error handling and then reraising the same exception in python.  
Right now, I'm doing it using the following code:

try:
    ...
except Foo:
    ...
except Bar:
    ...
except Exception, x:
    ...
    raise x
else:
    ...

which seems to work but I wanted to know if there are any problems with
this method  or if there is a better way to do it. The only potential problem
I know of right now is that user defined exception not derived from Exception
will slip through but is that much of a problem?

-- 
------------------------------------------------------------------
			    |
Suchandra Thapa             | "There are only two kinds of math books. 
s-thapaNO at SPAMuchicago.edu  | Those you cannot read beyond the first 
			    | sentence, and those you cannot read 
			    | beyond the first page."
			    |                       -C.N. Yang
------------------------------------------------------------------



More information about the Python-list mailing list