Why doesn't os.remove work on directories?

Laurent Delacroix laurent at krutt.org
Thu Dec 24 07:58:45 EST 2015


On 23/12/15 05:29, Random832 wrote:
> 
> This is surprising to anyone accustomed to the POSIX C remove
> function, which can remove either files or directories.  Is there
> any known rationale for this decision?
> 

Hello, in POSIX C the remove() function is actually rmdir() when called
on a directory: http://bit.ly/1NE1rfZ

I'm not sure about the rationale behind raising OSError if the argument
is a directory though. Maybe the "There should be one-- and preferably
only one --obvious way to do it." philosophy explains it. :-)

Lau



More information about the Python-list mailing list