removing directories

Martin Skøtt mskott at image.dk
Thu Dec 28 01:56:33 CET 2000


<abouf066 at aix2.uottawa.ca> writes:

> Greetings,
> 
> 	Is there a way to force removal of directories even if they
> contain files and/or directories. I just tried 
> 
> os.rmdir( path ) and removedirs ( path)
> 
> both functions complain about existence of files !?


I just tested shutil.rmtree on my Linux box with Python 1.5.1 and it
deletes a directory with files and subdirectories without
complaining. I didn't put in any other options than the path.
It is my experience that shutil is a lot easier to use than os, but
also more lethal (easier to make mistakes and do to much).
-- 
Med venlig hilsen
Martin Skøtt
mskott at image.dk

Believe nothing no matter where you read it or who has said it, not even if I
have said it, unless it agrees with your own reason and your own common sense. 
--Buddha



More information about the Python-list mailing list