I wasn't clear enough in my original post.

I know how to raise a basic OSError or IOError, but what if I want to raise specifically an "OSError: [Errno 2] No such file or directory"?
Somehow it must be possible to raise the error with the correct information to bring up the standard message, but where do I find the right values to give?

Thanks,
-Dave


alisonken1 wrote:
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.

  

-- 
Presenting:
mediocre nebula.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to