Python os.supports_follow_symlinks Object
-
Syntax of Python
os.supports_follow_symlinks
Method -
Example 1: Use the
os.supports_follow_symlinks
Object in Python -
Example 2: Use the
os.supports_follow_symlinks
Object to Check if a Method Allowsfollow_symlinks
Parameter

Python os.supports_follow_symlinks
Object is an efficient way of checking whether a specific OS module allows a method to use their follow_symlinks
parameter or not.
Many platforms provide various functionality, so we need to check if a function is available for use in Python.
Syntax of Python os.supports_follow_symlinks
Method
os.supports_follow_symlinks
Parameters
It is a non-callable object, so no parameter is required.
Return
The return type of this method is a set object representing all the methods in the OS module that allows the use of their follow_symlinks
argument.
Example 1: Use the os.supports_follow_symlinks
Object in Python
import os
List = os.supports_follow_symlinks
print(
"Following are the method that allows their follow_symlinks parameter to be used: ",
List,
)
Output:
Following are the method that allows their follow_symlinks parameter to be used: {<built-in function link>, <built-in function access>, <built-in function chown>, <built-in function utime>, <built-in function stat>}
Note that to determine whether any Python method permits using its follow_symlinks
parameter, we can use the in
operator on the supports_follow_symlinks
set.
Example 2: Use the os.supports_follow_symlinks
Object to Check if a Method Allows follow_symlinks
Parameter
import os
permission = os.stat in os.supports_follow_symlinks
print("Does it permit that its parameter is used? ", permission)
permission = os.lstat in os.supports_follow_symlinks
print("Does it permit that its parameter is used? ", permission)
Output:
Does it permit that its parameter is used? True
Does it permit that its parameter is used? False
In the above code, we are checking whether the os.stat()
method allows its follow_symlinks
parameter to be used on local platforms or not.
Musfirah is a student of computer science from the best university in Pakistan. She has a knack for programming and everything related. She is a tech geek who loves to help people as much as possible.
LinkedIn