I like the idea of this sort of capability - although I don’t know how common it will be in practice. I don’t really care how it gets spelled, but I think the bigger question is what’s going to happen to shutil
.
Ultimately, the question that needs to be answered is what we want people to reach for if they want to copy a directory structure from A to B. The “one obvious way”, to put it in terms of the Zen. At the moment that’s shutil
, because that contains “high level file operations”, implemented in a way that’s maximally efficient. Will src.copytree(dst)
be maximally efficient? For example, will it use os.sendfile
on Linux? What if dst
is a tarfile? Is it the responsibility of the implementer of src
or dst
to make sure the optimal approach is used?
What will happen to the 5 options to shutil.copytree
? Will PathBase.copytree
need to support them (so all subclasses will, as well), or will pathlib
be “the obvious approach unless you want to ignore certain files in the tree (for example)”? And what about shutil.copy
vs shutil.copy2
- which one will PathBase.copy
replace?
I’m inclined to say that yes, PathBase
should have copy
, copytree
, rmtree
and move
methods. To me, that’s the most attractive and flexible API. But that assumes that shutil
as it stands, with its 2 copy
functions, 5 optional args to copytree
, and 4 options to rmtree
, is massively over-engineered. And I’m not sure that’s true - I’ve seen a lot of those options used.
Sorry. More questions than answers here, I’m afraid…