[Python-ideas] New PEP proposal -- Pathlib Module Should Contain All File Operations -- version 2
eryksun at gmail.com
Sun Mar 25 19:38:16 EDT 2018
On Sat, Mar 17, 2018 at 10:42 AM, George Fischhof <george at fischhof.hu> wrote:
> All functions from os module accept path-like objects,
> and none of the shutil functions.
shutil indirectly supports __fspath__ paths via os and os.path. One
exception is shutil.disk_usage() on Windows, which only supports str
strings. This is fixed in 3.7, in resolution of issue 32556. Maybe it
should be backported to 3.6.
I like the idea of a high-level library that provides a subset of
commonly used os, io, and shutil functionality in one place. But maybe
a new module isn't required. shutil could be extended since its design
goal is to provide "high-level operations on files and collections of
That said, pathlib's goal to support "concrete paths [that] provide
I/O operations" does seem incomplete. It should support copy,
copytree, rmtree, and move methods. Also, a `parents` option should be
added to Path.rmdir to implement removedirs, which mirrors how
Path.mkdir implements makedirs.
> os.link => path.hardlink_to
I'm surprised this doesn't already exist.
More information about the Python-ideas