Python os.readlink() Method
os.readlink() Overview
The os.readlink() method is used to return the file to which the softlink points, and may return absolute or relative paths.
Valid in Unix.
os.readlink() Syntax
The readlink() method syntax format is as follows.
os.readlink(path)
os.readlink() Parameters
- path – the softlink path to look for.
os.readlink() Return Value
Returns the file to which the soft link points.
os.readlink() Example
The following example demonstrates the use of the readlink() method.
#!/usr/bin/python3
import os
src = '/usr/bin/python'
dst = '/tmp/python'
# Create soft links
os.symlink(src, dst)
# Using soft links to display source links
path = os.readlink( dst )
print (path)
Output: