rm -rf in python
mwh21 at cam.ac.uk
Sat Feb 24 16:54:19 EST 2001
"David Allen" <s2mdalle at titan.vcu.edu> writes:
> In article <m3hf1jsryl.fsf at atrus.jesus.cam.ac.uk>, "Michael Hudson"
> <mwh21 at cam.ac.uk> wrote:
> > "David Allen" <s2mdalle at titan.vcu.edu> writes:
> >> I need to write the equivalent of "rm -rf" in python, so I wrote this, but
> >> I'm having a hard time understanding why it's not working.
> > [schnipp]
> >> Any help would be appreciated.
> > I haven't read your code, but do you know about shutil.rmtree?
> I hadn't until now...
> Searching yields:
> Question: I'm not seeing in the documentation for
> this whether or not it's good on windows machines.
> Is it? In my original code I had to be careful to
> use os.sep rather than just "/" because this code
> will have to run on microsoft OS's.
>From glancing at the source, I'd say it should work. It does its
stuff by building up a list of tuples of the form
(building up the paths using os.path.join) and then rattles through
for a, b in list_of_tuples:
I don't know how old the module is, but I think it was in 1.5.2 (and
if this turns out to be a problem you can just nick the code from
I really hope there's a catastrophic bug insome future e-mail
program where if you try and send an attachment it cancels your
ISP account, deletes your harddrive, and pisses in your coffee
-- Adam Rixey
More information about the Python-list