all Python 3osfunction
os.link
os — links
Creates a hard link to a file (a second name for the same inode).
Syntax
os.link(...)
A hard link is a second name for the same data: a change through one name is visible through the other, and the data disappears only when every name is removed (counted in st_nlink). Links work only within one filesystem and usually cannot point to directories. On Windows they work since 3.2, on NTFS only.
Examples
import os
open('link_src.txt', 'w').close()
os.link('link_src.txt', 'link_src.txt_l')
print(os.path.exists('link_src.txt_l')) # → True
os.remove('link_src.txt_l')
os.remove('link_src.txt')
See also
Common errors
Open in the full glossarydocs.python.orgReport an inaccuracy