how to find if the file is a link file, and find the path of the target file (actual file pointed by the link file)
views:
57answers:
2
+3
A:
os.path.islink
(is it a link?) and os.path.realpath
(get ultimate pointed to path, regardless of whether it's a link).
If os.path.islink
is True, and you only want to follow the first link, use os.readlink
.
Matthew Flaschen
2010-07-09 12:56:34
os.path.realpath doesnot give the path of the actual target file's path as said.
duhhunjonn
2010-07-09 13:22:29
Looks like `os.path.realpath` does resolve symbolic links, including multiply-linked (multiply-nested?) symlinks.
dcrosta
2010-07-09 14:47:59