Os Readlink
# Python2.x Python os.readlink() Method
[ Python OS File/Directory Methods](#)
* * *
### Overview
The os.readlink() method is used to return the file pointed to by a symbolic link. It may return an absolute or relative path.
Valid on Unix
### Syntax
The syntax for the **readlink()** method is as follows:
os.readlink(path)
### Parameters
* **path** -- The path of the symbolic link to look up
### Return Value
Returns the file pointed to by the symbolic link
### Example
The following example demonstrates the use of the readlink() method:
#!/usr/bin/python# -*- coding: UTF-8 -*-import os src = '/usr/bin/python' dst = '/tmp/python'# Create symbolic link os.symlink(src, dst)# Use symbolic link to display source link path = os.readlink( dst )print path
The output of executing the above program is:
/usr/bin/python
[ Python OS File/Directory Methods](#)
YouTip