[issue38627] Add copy() method to pathlib

Sebastian Linke report at bugs.python.org
Tue Oct 29 01:55:17 EDT 2019


New submission from Sebastian Linke <Seb_Linke at arcor.de>:

pathlib.Path() could wrap shutil.copy() with something like this:

def copy(self, target):
    if not self.is_file():
        # No support for directories here
        raise ValueError("Path must point to a regular file")
    # copy() appends filename when Path is copied to a directory
    # see shutil.copy() docstring and source for details
    target = shutil.copy(self, target)
    return self.__class__(target)

----------
components: Library (Lib)
messages: 355616
nosy: seblin
priority: normal
severity: normal
status: open
title: Add copy() method to pathlib
type: enhancement
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38627>
_______________________________________


More information about the Python-bugs-list mailing list