diff options
author | Steve Dower <steve.dower@python.org> | 2021-04-07 17:12:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-07 17:12:42 (GMT) |
commit | 34f93002bac980176a670ce2a4038c3be84effed (patch) | |
tree | a47323bc029cd4812df716d86b11b4d30ceb4c80 /Lib/pathlib.py | |
parent | a21d4fbd549ec9685068a113660553d7f80d9b09 (diff) | |
download | cpython-34f93002bac980176a670ce2a4038c3be84effed.zip cpython-34f93002bac980176a670ce2a4038c3be84effed.tar.gz cpython-34f93002bac980176a670ce2a4038c3be84effed.tar.bz2 |
bpo-42999: Expand and clarify pathlib.Path.link_to() documentation. (GH-24294)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
Diffstat (limited to 'Lib/pathlib.py')
-rw-r--r-- | Lib/pathlib.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/Lib/pathlib.py b/Lib/pathlib.py index 147be2f..da51a4f 100644 --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -1358,12 +1358,6 @@ class Path(PurePath): """ return self._accessor.lstat(self) - def link_to(self, target): - """ - Create a hard link pointing to a path named target. - """ - self._accessor.link_to(self, target) - def rename(self, target): """ Rename this path to the target path. @@ -1392,11 +1386,23 @@ class Path(PurePath): def symlink_to(self, target, target_is_directory=False): """ - Make this path a symlink pointing to the given path. - Note the order of arguments (self, target) is the reverse of os.symlink's. + Make this path a symlink pointing to the target path. + Note the order of arguments (link, target) is the reverse of os.symlink. """ self._accessor.symlink(target, self, target_is_directory) + def link_to(self, target): + """ + Make the target path a hard link pointing to this path. + + Note this function does not make this path a hard link to *target*, + despite the implication of the function and argument names. The order + of arguments (target, link) is the reverse of Path.symlink_to, but + matches that of os.link. + + """ + self._accessor.link_to(self, target) + # Convenience functions for querying the stat results def exists(self): |