[Tutor] If I use this code will it delete my program fileS?

Wayne Werner waynejwerner at gmail.com
Fri Jan 21 04:52:04 CET 2011


On Thu, Jan 20, 2011 at 9:32 PM, walter weston <hacker0100 at hotmail.com>wrote:

>  I have a question I know the shutil module deletes directories, If I use
> this code will it delete all of my program files?
>
> import shutil
> shutil.rmtree('C:\Program Files (x86)')
>


Assuming you have the proper permissions, yes.

An easy and safe(ish) way to test this would be to create a directory and
populate it with subdirectories and files, then try calling rmtree() on that
directory. Of course it's also safer to use forward slashes in your
directory. For instance, if you had rmtree('C:\test'), it will try to remove
the directory that has a tab character in it.

HTH,
Wayne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110120/9e6d3812/attachment.html>


More information about the Tutor mailing list