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