For python 3.4 and above, you can use the Path class
from pathlib import Path
You must be careful when using the is_symlink () method. It will return True, even if the target of the link is missing, if the named object is a symbolic link. For example (Linux / Unix):
ln -s ../nonexistentfile flnk
Then in your current directory run python
>>> from pathlib import Path >>> Path('flnk').is_symlink() True >>> Path('flnk').exists() False
The programmer must decide what he / she really wants. Python 3 seems to have renamed many classes. Maybe you should read the manual page for the Path class: https://docs.python.org/3/library/pathlib.html
Kemin Zhou Sep 04 '16 at 4:39 on 2016-09-04 04:39
source share