pathlib.Path.symlink_to()

Path.symlink_to(target, target_is_directory=False)

Make this path a symbolic link to target. Under Windows, target_is_directory must be true (default False) if the link’s target is a directory. Under POSIX, target_is_directory‘s value is ignored.

>>> p = Path('mylink')
>>> p.symlink_to('setup.py')
>>> p.resolve()
PosixPath('/home/antoine/pathlib/setup.py')
>>> p.stat().st_size
956
>>> p.lstat().st_size
8

Note

The order of arguments (link, target) is the reverse of os.symlink()‘s.

doc_python
2016-10-07 17:40:32
Comments
Leave a Comment

Please login to continue.