On Tue, 26 Apr 2005 21:33:52 -0500, rumours say that Mike Meyer
<[EMAIL PROTECTED]> might have written:

>This is just a little bit tricky. os.remove (on FreeBSD 5-STABLE,
>anyway) throws an OSError exception if it doesn't have permission to
>remove the file, *or* if the file doesn't exist. You have to examine
>the exception for it's value, which is the result of a strerror
>call. I believe that the result of strerror is platform dependent.

Although I don't have experience with FreeBSD, so far checking the
exception's errno args does the job.  Example:

import errno

try:
   ...
except OSError, exc:
        if exc.errno == errno.ENOENT: # file inexistant
      ...
        elif exc.errno == errno.EPERM: # no permissions
      ...
   else:
      raise
-- 
TZOTZIOY, I speak England very best.
"Be strict when sending and tolerant when receiving." (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to