diff options
author | Miss Skeleton (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-10-03 10:44:14 (GMT) |
---|---|---|
committer | Ćukasz Langa <lukasz@langa.pl> | 2020-10-04 15:30:49 (GMT) |
commit | 5533c4952cd6c44c63274874be7de06495b914ea (patch) | |
tree | 06d7dfb73d009114b762b48072546674ca6aefd5 /Lib | |
parent | fd3d00adb08c0b6530c2730a917cf20bbd8faba3 (diff) | |
download | cpython-5533c4952cd6c44c63274874be7de06495b914ea.zip cpython-5533c4952cd6c44c63274874be7de06495b914ea.tar.gz cpython-5533c4952cd6c44c63274874be7de06495b914ea.tar.bz2 |
[3.9] bpo-40833: Clarify Path.rename doc-string regarding relative paths (GH-20554)
(cherry picked from commit f97e42ef4d97dee64f45ed65170a6e77c8e46fdf)
Co-authored-by: Ram Rachum <ram@rachum.com>
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/pathlib.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/Lib/pathlib.py b/Lib/pathlib.py index babc443..147be2f 100644 --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -1366,17 +1366,26 @@ class Path(PurePath): def rename(self, target): """ - Rename this path to the given path, - and return a new Path instance pointing to the given path. + Rename this path to the target path. + + The target path may be absolute or relative. Relative paths are + interpreted relative to the current working directory, *not* the + directory of the Path object. + + Returns the new Path instance pointing to the target path. """ self._accessor.rename(self, target) return self.__class__(target) def replace(self, target): """ - Rename this path to the given path, clobbering the existing - destination if it exists, and return a new Path instance - pointing to the given path. + Rename this path to the target path, overwriting if that path exists. + + The target path may be absolute or relative. Relative paths are + interpreted relative to the current working directory, *not* the + directory of the Path object. + + Returns the new Path instance pointing to the target path. """ self._accessor.replace(self, target) return self.__class__(target) |