
On 22 Jun 2015 17:59, "Paul Moore" <p.f.moore@gmail.com> wrote:
On 22 June 2015 at 15:59, Chris Angelico <rosuav@gmail.com> wrote:
On Mon, Jun 22, 2015 at 6:30 PM, David Townshend <aquavitae69@gmail.com>
wrote:
3. There are several other minor irritations where a common pattern requires several lines or the use of a lower-level library such as shutil. For example:
* Recursively remove a directory (no sane way using pathlib alone) shutil.rmtree(str(path))
I'm not sure shutil should be considered a lower-level library. It's a separate set of tools aimed at shell-like functionality. Removing a directory tree seems right for shutil; what if shutil.rmtree() would accept a Path object as an alternative to a str? That'd make reasonable sense, and it'd feel like the two modules were working well together.
Agreed, shutil is higher level than pathlib, not lower.
Having more stdlib functions (shutil is the most obvious example, but there are others) take pathlib.Path objects as well as strings would be a good change (and would set a nice example for 3rd party file manipulation modules). I'm sure the usual "patches welcome" applies :-)
The main irritation about using "higher level" modules with path objects is the proliferation of str() calls. Accepting path objects natively fixes that:
from shutil import rmtree rmtree(path)
looks fine to me.
Paul _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
I was going on the fact that the PEP talks about possibly including shutil functions, but I have no problem with making them accept Paths instead. If that's the best approach I'll see if I can put together a patch. David