Find out link location

Padraig Brady Padraig at Linux.ie
Mon Sep 30 09:12:39 EDT 2002


Padraig Brady wrote:
> Klaus Hoeppner wrote:
> 
>> Hi,
>>
>> with the os.path module I can use the islink function to check, wether
>> a file is symbolic link. But how can I find out, where the link points
>> to. E.g. if I have readme.txt --> ../packages/mypackage/readme.txt how
>> do I get the "../packages/mypackage/readme.txt" with python?
> 
> import os
> filter (lambda x: x.find("link") != -1, dir(os))

To be a little more modern:

[x for x in dir(os) if x.find("link") != -1]

Pádraig.




More information about the Python-list mailing list