deleting directory tree

Kragen Sitaker kragen at canonical.org
Wed Nov 21 08:33:49 CET 2001


Tom Harris <TomH at optiscan.com> writes:
> Can someone explain what os.removedirs() does? I needed a function to remove
> a directory and all its files and subdirectories, and ended up writing one.
> It seems that there should be such a function in os, but I drew a blank.

I thought the same  thing earlier today.  I  read the manual entry and
thought, "Surely this can't mean what it says."  But it does.

removedirs() is just like makedirs(), but in reverse.  Point it at a
directory and it will remove it, along with any ancestor directories
with no purpose in life other than to contain that directory.  I can't
imagine why anyone would ever want this.




More information about the Python-list mailing list