This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Rockmizu
Recipients Rockmizu
Date 2020-01-10.17:50:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1578678614.26.0.0980677925629.issue39291@roundup.psfhosted.org>
In-reply-to
Content
Python version: Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32

The usage of symlink_to() is link.symlink_to(target)
while the usage of link_to() is target.link_to(link).
This could be confusing.

Here is an example:

>>> import pathlib
>>> target = pathlib.Path('target.txt')
>>> p1 = pathlib.Path('symlink.txt')
>>> p2 = pathlib.Path('hardlink.txt')
>>> p1.symlink_to(target)
>>> p2.link_to(target)  # expected usage
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Program Files\Python38\lib\pathlib.py", line 1346, in link_to
    self._accessor.link_to(self, target)
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'hardlink.txt' -> 'target.txt'
>>> target.link_to(p2)  # current usage
>>>

Since os.symlink() and os.link() have the same argument order,

>>> import os
>>> os.symlink('target.txt', 'symlink.txt')
>>> os.link('target.txt', 'hardlink.txt')
>>>

it would be nicer if the pathlib has the same argument order too.
History
Date User Action Args
2020-01-10 17:50:14Rockmizusetrecipients: + Rockmizu
2020-01-10 17:50:14Rockmizusetmessageid: <1578678614.26.0.0980677925629.issue39291@roundup.psfhosted.org>
2020-01-10 17:50:14Rockmizulinkissue39291 messages
2020-01-10 17:50:13Rockmizucreate