[Python-ideas] Adding optional parameter to shutil.rmtree to not delete root.
Nick Jacobson
nicksjacobson at yahoo.com
Thu Aug 25 15:27:42 EDT 2016
+1 for clear_dir()
I agree that there's no other obvious meaning that it could have.
On Thursday, August 25, 2016 9:44 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
On 25 August 2016 at 23:14, Victor Stinner <victor.stinner at gmail.com> wrote:
> Maybe add a different function rather add a flag? Something like
> shutil.remove_dir_files().
The typical Python term for the concept would be "clear", giving
shutil.clear_dir(). Like the ".clear()" method on containers, it would
delete the contents, but leave the container itself alone. rmtree()
could then be a thin wrapper around clear_dir() that also deletes the
base directory.
Alternatively, if we wanted to stick with the "rm" prefix, we could
use "shutil.rmcontents()" as the name. The main downside I'd see to
that is that I'd half expect it to work on files as well (truncating
them to a length of zero), while clear_dir() is unambiguous.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160825/efdd7892/attachment.html>
More information about the Python-ideas
mailing list