New submission from Charles Machalow <csm10...@gmail.com>:

I think it would make sense to add a recurse flag to the Path.rmdir() method. 
It would default to False (to allow for current behavior). If set to True, the 
method would act very similarly to shutil.rmtree() in that it would delete all 
files in the directory and then delete the directory itself.

I understand that this behavior doesn't really line up with os.rmdir(), though 
I think it makes sense to allow this type of method to appear on the Path 
object for easy deletion of a directory with things still inside (while looking 
more object-oriented at the same time)

If people think this makes sense, I may be able to provide a PR to just 
delegate to shutil.rmtree for the recurse=True operation.

Thanks for thoughts.

----------
components: Library (Lib)
messages: 371487
nosy: Charles Machalow
priority: normal
severity: normal
status: open
title: Add a recurse flag to Path.rmdir()
type: enhancement
versions: Python 3.10, Python 3.8, Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue40972>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to