In article <[EMAIL PROTECTED]>,
David Hirschfield <[EMAIL PROTECTED]> wrote:
>When I attempt to perform a file operation on a non-existent file, I get
>an OSError: [Errno 2], but what if I want to raise one of those myself?
raise OSError(2, "No such file or directory")
--
http://mail.python.or
Looking at the Python docs.. I found this:
http://docs.python.org/ext/errors.html
"""
Another useful function is PyErr_SetFromErrno(), which only takes an
exception argument and constructs the associated value by inspection
of the global variable errno. The most general function is
PyErr_SetObject
I do not see the point in doing so (why not just copy+paste that
string?), but the errno (specifically ENOENT) corresponds to the
POSIX.1 error number, and the string "No such file or directory" is
done in C via strerror(ENOENT); (check errno(3) and strerror(3)).
I doubt there is something that do
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, b
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
I know this should be obvious, but how does one raise a specific type of
OSError?
When I attempt to perform a file operation on a non-existent file, I get
an OSError: [Errno 2], but what if I want to raise one of those myself?
Thanks in advance,
-Dave
--
Presenting:
mediocre nebula.
--
http: