delete will assure file is deleted?
Christos TZOTZIOY Georgiou
tzot at sil-tec.gr
Wed Apr 27 08:59:45 EDT 2005
On Tue, 26 Apr 2005 21:33:52 -0500, rumours say that Mike Meyer
<mwm at mired.org> 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...
More information about the Python-list
mailing list