delete will assure file is deleted?

Mike Meyer mwm at mired.org
Tue Apr 26 22:24:06 EDT 2005


Jeremy Bowers <jerf at jerf.org> writes:

> On Tue, 26 Apr 2005 03:40:16 -0700, ajikoe at gmail.com wrote:
> os.remove, as the module name implies, tells the OS to do something. I
> would consider an OS that returned from a "remove" call, but still let you
> access that file, highly broken. 

Um - not if you have permission to read the file, but don't have
permission to remove it. Whatever the "remove" call does in this case,
you *better* have access to it after the fact.  The "remove" call on
Unix (uka "unlink") returns even if it can't remove the file: it
returns 0 if it succeeds, and -1 if it doesn't.

os.remove is a little brighter than that. It will throw an OSError
exception if it can't remove the file.

          <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list