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. |