[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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 demonstrated. And you 
can easily modify it if your needs change (for example if you decide to not 
copy links). Not every three lines of code should be added as a function to the 
stdlib.

--
nosy: +serhiy.storchaka
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 to the target is created.
If target points to an existing file, that file is overwritten.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com