Of course, shutil.rmtree() is a fast and direct method, but still a little warning, it could be dangerous. No warning and ensure will be raised while removing a tree of files.
Juan Shen
Kent Johnson wrote:


You misunderstand what removedirs does. It removes an empty directory; then, if the removed directory's parent is now empty, it removes that, too, and so on until it finds a directory with something in it or gets up to the root.

Try shutil.rmtree() or this recipe:
http://aspn.activestate.com/ASPN/docs/ActivePython/2.2/PyWin32/Recursive_directory_deletes_and_special_files.html



Kent

Ertl, John wrote:

I am trying to remove a directory that has other directories and files in
it. I thought removedirs was supposed to do a recursive remove of files and
directories.


When I try it I get

os.removedirs("DAF")



Traceback (most recent call last):
  File "<pyshell#11>", line 1, in -toplevel-
    os.removedirs("DAF")
  File "/home/ertlj/ertljVersion/lib/python2.3/os.py", line 167, in
removedirs
    rmdir(name)
OSError: [Errno 17] File exists: 'DAF'

Thanks,

John Ertl

_______________________________________________
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor




_______________________________________________
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to