Symbolic links on Windows
ast
ast at invalid
Wed Nov 17 06:12:29 EST 2021
Hello,
It seems that symbolic links on Windows are not
well reconized by modules os or pathlib.
I have a file named json.txt on my destop. With a
drag and drop right click on it I create a link
automatically named: json.txt - Raccourci.lnk
Then:
>>> from pathlib import Path
>>> p2 = Path('C:/Users/jm/desktop/json.txt - Raccourci.lnk')
>>> p2
WindowsPath('C:/Users/jm/desktop/json.txt - Raccourci.lnk')
>>> p2.exists()
True
>>> p2.is_file()
True
>>> p2.is_symlink()
False
With this last command I was expecting True and for
p2_is_file() I was expecting False
With os, it's the same
import os
>>> os.path.exists(p2)
True
>>> os.path.isfile(p2)
True
os.path.islink(p2)
False
What's wrong plz ?
More information about the Python-list
mailing list