Remove diretory with files in it

Stefan Schwarzer sschwarzer at sschwarzer.net
Sun Aug 25 16:00:42 CEST 2002


Hello Paul

Paul Rubin wrote:
>>I can;'t  seem to make the os.rmdir()path) command to work the way I
>>need it .  I would like it to be like" rm -rf" in unix .  It keeps
>>throwing an exception about not being empty.  Is there a way to rmove
>>a directory and it's contents in python?
> 
> You have to remove all the contents before you can rmdir a directory.
> Using os.system("rm -rf directory") is probably the simplest.

... unless you plan to write portable code not only for Unix. ;-)

Stefan




More information about the Python-list mailing list