Reputation: 20405
Give
$ ll ./
$ foo1
$ foo2 -> /absolute/path/to/bar2
$ foo3 -> bar3
I know
os.path.islink()
tells me if a file is a symlink.
I also know
os.path.realpath()
gives me the real, absolute path of a symlink. I have no problems with it returning me /absolute/path/to/bar2
for os.path.realpath('foo2')
.
But for os.path.realpath('foo3')
, I want bar3
("as is" in the title).
Is there a simpler way than computing relpath
with foo3
's directory as start?
Upvotes: 1
Views: 59