Python os.R_OK Constant
Example
Try to access file with different mode parameters:
# import os Library
import os
# Check access with os.F_OK
path1 = os.access("text.txt", os.F_OK)
print("Does the path exists:",
path1)
# Check access with os.R_OK
path2 = os.access("text.txt",
os.R_OK)
print("Access to read the file:", path2)
# Check access
with os.W_OK
path3 = os.access("text.txt", os.W_OK)
print("Access to
write to file:", path3)
# Check access with os.X_OK
path4 =
os.access("text.txt", os.X_OK)
print("Can path be executed:", path4)
Run Code »
Definition and Usage
The os.R_OK
constant is used in the mode
parameter of the
os.access()
method, to test the readability of the path.
Note: Available on both UNIX and WINDOWS platforms.
Syntax
os.R_OK
Technical Details
Return Value: | None |
---|---|
Python Version: | pre-2.6 |