<html><head></head><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_1_1472090385940_16176">I've been finding that a common scenario is where I want to remove everything in a directory, but leave the (empty) root directory behind, not removing it.</div><div id="yui_3_16_0_1_1472090385940_16177"><br id="yui_3_16_0_1_1472090385940_16178"></div><div id="yui_3_16_0_1_1472090385940_16179">So for example, if I have a directory C:\foo and it contains subdirectory C:\foo\bar and file C:\foo\myfile.txt, and I want to remove the subdirectory (and everything in it) and file, leaving only C:\foo behind.</div><div id="yui_3_16_0_1_1472090385940_16180"><br id="yui_3_16_0_1_1472090385940_16181"></div><div id="yui_3_16_0_1_1472090385940_16182">(This is useful e.g. when the root directory has special permissions, so it wouldn't be so simple to remove it and recreate it again.)</div><div id="yui_3_16_0_1_1472090385940_16183"><br id="yui_3_16_0_1_1472090385940_16184"></div><div id="yui_3_16_0_1_1472090385940_16185">A number of ways to do this have been offered here: http://stackoverflow.com/questions/185936/delete-folder-contents-in-python</div><div id="yui_3_16_0_1_1472090385940_16186"><br></div><div id="yui_3_16_0_1_1472090385940_16188">But it'd be simpler if there were an optional parameter added to shutil.rmtree, called removeroot. It would default to true so as to not break any backward compatibility. If it's set to false, then it leaves the root directory in place.</div><div id="yui_3_16_0_1_1472090385940_16189"><br></div><div id="yui_3_16_0_1_1472090385940_16191">Thanks,</div><div id="yui_3_16_0_1_1472090385940_16192"><br id="yui_3_16_0_1_1472090385940_16193"></div><div id="yui_3_16_0_1_1472090385940_16194">Nick</div><div dir="ltr" id="yui_3_16_0_1_1472090385940_16195"><br id="yui_3_16_0_1_1472090385940_16196"></div></div></body></html>