[New-bugs-announce] [issue33498] pathlib.Path wants an rmtree method

Aaron Hall report at bugs.python.org
Mon May 14 10:30:35 EDT 2018


New submission from Aaron Hall <aaronchall at yahoo.com>:

pathlib.Path wants the rmtree method from shutil

I think we need this method for a couple of reasons.

1. in shell, rm has the -r flag - In Python, we use shutil.rmtree as a best practice for this.

2. I prefer to teach my students about pathlib.Path as opposed to other ways of dealing with files. It's a great abstraction. But it's somewhat leaky, especially when it comes to recursively deleting a directory with its contents, as I now need to import rmtree from shutil.

Perhaps we need this as a method in the abstract base class that recursively uses the methods provided by the concrete implementations. I can look at the rmtree method for a reference implementation. 

Perhaps we should just give Path.rmdir a default recursive argument? Default would be False, of course, to retain current behavior.

----------
components: Library (Lib)
messages: 316511
nosy: Aaron Hall
priority: normal
severity: normal
status: open
title: pathlib.Path wants an rmtree method
type: enhancement
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33498>
_______________________________________


More information about the New-bugs-announce mailing list