[issue38627] Add copy() method to pathlib

2019-10-29 Thread Brett Cannon
Brett Cannon added the comment: And just to add Serhiy's logic, think of pathlib more as an equivalent to os.path than a be-all solution to anything path-related. -- nosy: +brett.cannon ___ Python tracker

[issue38627] Add copy() method to pathlib

2019-10-29 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Since shutil.copy() accepts path-like object, I do not think there is a need to add the copy method to Path. As for additional limitation, it looks arbitrary and application specific. You can easy implement a simple helper function as you just

[issue38627] Add copy() method to pathlib

2019-10-29 Thread Sebastian Linke
Sebastian Linke added the comment: Docstring could be: Copy file content and permission bits of this path to the target path and return a new Path instance pointing to the target path. If target is a directory, the base filename of this path is added to the target and a new file corresponding

[issue38627] Add copy() method to pathlib

2019-10-28 Thread Sebastian Linke
New submission from Sebastian Linke : 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