Raising a specific OSError
alisonken1
alisonken1 at gmail.com
Fri Apr 21 18:44:17 EDT 2006
To raise a specific error, just find the error that you want to raise,
then give the error a text string to print: ex.
raise IOError("This raises an IO error")
On the stderr output, when the routine hits this line, you will get:
>>> raise IOError("This raises an IOError")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
IOError: This raises an IOError
>>>
Just be sure of the error that you want to raise, since some of them
will do stuff like closing open file descriptors as well.
More information about the Python-list
mailing list