rm -rf in python?

Vasisht Tadigotla vasisht at eden.rutgers.edu
Fri Nov 15 00:25:37 EST 2002


> Is there a way (short of executing a shell command) that I can do a rm
> -rf on a directory from python?  It raises an OSError if you try to
> delete a directory that has contents.  I suppose that I could recurse
> down through, deleteing as I went, but it seems that there must be an
> easier way.

use the  rmtree() function in shutil module, works on *nix. i don't think
it works on windows though.

vasisht



---------------------------------------------------------------------
"A cat spends her life conflicted between a deep, passionate and profound
desire for fish and an equally deep, passionate and profound desire to
avoid getting wet.  This is the defining metaphor of my life right now."








More information about the Python-list mailing list