<p dir="ltr">Maybe add a different function rather add a flag? Something like shutil.remove_dir_files().</p>
<p dir="ltr">Victor</p>
<div class="gmail_extra"><br><div class="gmail_quote">Le 25 août 2016 4:32 AM, "Nick Jacobson via Python-ideas" <<a href="mailto:python-ideas@python.org">python-ideas@python.org</a>> a écrit :<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="color:#000;background-color:#fff;font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px"><div>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><br></div><div>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><br></div><div>(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><br></div><div>A number of ways to do this have been offered here: <a href="http://stackoverflow.com/questions/185936/delete-folder-contents-in-python" target="_blank">http://stackoverflow.com/<wbr>questions/185936/delete-<wbr>folder-contents-in-python</a></div><div><br></div><div>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><br></div><div>Thanks,</div><div><br></div><div>Nick</div><div dir="ltr"><br></div></div></div><br>______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br></blockquote></div></div>