os.remove & os.rmdir
Padraig Brady
padraig.brady at corvil.com
Thu Jan 9 05:08:52 EST 2003
Tim Roberts wrote:
> Padraig Brady <padraig.brady at corvil.com> wrote:
>
>>Peter Hansen wrote:
>>
>>>Padraig Brady wrote:
>>>
>>>>So, should I do a simple patch?
>>>
>>>Please don't!
>>>
>>>
>>>>Advantages I can see are:
>>>>
>>>> 1. It follows the standard
>>>
>>>Which standard? This is Python, not C.
>>
>>POSIX and ISO C. Having different functionality than those
>>is confusing I think.
>
> ISO C does not say this. The spec only says that "remove" deletes a file.
> In response to a request for interpretation, the behavior when a directory
> name is given was officially deemed "unspecified".
Hmm, so POSIX is doing the specifying here?
http://www.opengroup.org/onlinepubs/007904975/functions/remove.html
Trust M$ to be different.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_remove.2c_._wremove.asp
So I guess that means we should explicitly do this in the os module:
If os.path.isdir(path):
os.rmdir(path)
else:
os.unlink(path)
Pádraig.
More information about the Python-list
mailing list