[Python-ideas] Pathlib additions & changes
David Townshend
aquavitae69 at gmail.com
Mon Jun 22 18:44:27 CEST 2015
More information about the Python-ideas mailing list
Mon Jun 22 18:44:27 CEST 2015
- Previous message (by thread): [Python-ideas] Pathlib additions & changes
- Next message (by thread): [Python-ideas] millisecond and microsecond times without floats
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 22 Jun 2015 17:59, "Paul Moore" <p.f.moore at gmail.com> wrote: > > On 22 June 2015 at 15:59, Chris Angelico <rosuav at gmail.com> wrote: > > On Mon, Jun 22, 2015 at 6:30 PM, David Townshend <aquavitae69 at 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 at 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150622/724d0e84/attachment.html>
- Previous message (by thread): [Python-ideas] Pathlib additions & changes
- Next message (by thread): [Python-ideas] millisecond and microsecond times without floats
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list