Remove directory tree without following symlinks

Steven D'Aprano steve at pearwood.info
Fri Apr 22 13:14:12 EDT 2016


On Sat, 23 Apr 2016 01:09 am, Random832 wrote:

> On Fri, Apr 22, 2016, at 10:56, Steven D'Aprano wrote:
>> What should I use for "remove_tree"? Do I have to write my own, or does a
>> solution already exist?
> 
> In the os.walk documentation it provides a simple recipe and also
> mentions shutil.rmtree

Thanks for that.

The os.walk recipe is described as a simple version of shutil.rmtree. The
documentation for rmtree seems lacking to me, but after testing it, it
appears to work as I want it: it removes symbolic links, it does not follow
them.

Is anyone else able to confirm that my understanding is correct? If so, the
documentation should probably be a bit clearer.



-- 
Steven




More information about the Python-list mailing list