Exception Handling
Sheldon
shejo284 at gmail.com
Thu Jan 12 04:00:35 EST 2006
Hi,
This is a non-trivial thing that you are trying to do. You can use some
of python's built-in exceptions, like RuntimeError or IOError and if so
then:
try:
call C
except IOError, e:
print e
But this will return and print only IOErrors if they occur.
You can define your own error handling using the function RAISE:
try:
Call C
except:
raise my_error.
A catch-all error is RuntimeError; try this first.
try:
call C
except RuntimeError, r:
print r
You can read up on it here:
http://docs.python.org/api/standardExceptions.html
Cheers,
Sheldon
More information about the Python-list
mailing list