Currently, pathlib supports pretty much all common filesystem operations.
You can create, move, and delete both files and directories. One big
omission is copying. You need shutil for that.

Whatever the original intent might have been behind pathlib, it is now
effectively the standard tool for filesystem operations. As such, excluding
copying alone from basic operations creates an unnecessary hurdle for
users. It also increases the difficulty of doing such operations since
there is no hint within the pathlib documentation on how to copy, new users
basically need to google it to find out.  That is fine for less common
operations, but far from ideal from a basic one like copying.

So I think it would make a lot of sense to include copying inside pathlib.
I propose adding a `copy` method to `pathlib.Path` (for concrete paths).

The specific call signature would be:

copy(dst, *, follow_symlinks=True, recursive=True, dir_exist_ok=True)

This will call `shutil.copytree` for directories if recursive is True, or
`copy2` if recursive if False. For files it will call `copy2` always.

An alternative would be to have separate `copy` and `copytree` methods, but
in most situations I think copying on directories would want copying a tree.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/CRI43C2RM4VUEZLM4E7UYMGLPN4LV7J4/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to