Hello dear readers! Welcome back to another section of our tutorial on Python. In this tutorial guide, we are going to be studying about the Os readlink() method.
The Python os readlink() method returns a string that represents the path to which the symbolic link points. It may return an absolute or a relative pathname.
The Python os readlink() method returns a string that represents the path to which the symbolic link points. It may return an absolute or a relative pathname.
Syntax
The following below is the syntax for Python Os readlink() method -
os.readlink( path )
RECOMMENDED POST: Python os.popen() Method with example
Parameter Details
- path - It is the path for which we are going to find source of the link.
Return Value
This returns a string representing the path to which the symbolic link point to.
Example
The following below is a simple example -
# !/usr/bin/python import os src = '/usr/bin/python' dst = '/tmp/python' # This creates a symbolic link on python in tmp directory os.symlink(src, dst) # Now let us use readlink to display the source of the link. path = os.readlink( dst ) print path
Output
Let us compile and run the above program, this creates a symbolic link to usr/ben/python and later it will then read the source of the symbolic link using readlink() call. Before you run this program, make sure you do not have /tmp/Python already available.
/usr/bin/python
RECOMMENDED POST: Python os.read() Method with example
Alright guys! This is where we are rounding up for this tutorial post. In our next tutorial, we are going to be discussing about the Python OS remove() Method.
Feel free to ask your questions where necessary and i will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.
Feel free to ask your questions where necessary and i will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.