Skip to content

Commit ea203b1

Browse files
author
Vimal A.R
committed
* Day 24 of #100DaysofCode
* Understanding os.access() to check r,w,x and other features.
1 parent aecbd58 commit ea203b1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Day-024/01-os.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
5+
# __file__ can represent the code file that's
6+
# being run, hence we use it here to showcase
7+
# a few features of os.access()
8+
9+
# os.access() tests the access to a file using
10+
# the real uid/gid of the user executing the file
11+
12+
print("Calling {}".format(__file__))
13+
print("Does exist: {}".format(os.access(__file__, os.F_OK)))
14+
print("Is readable: {}".format(os.access(__file__, os.R_OK)))
15+
print("Is writable: {}".format(os.access(__file__, os.W_OK)))
16+
print("Is executable: {}".format(os.access(__file__, os.EX_OK)))

0 commit comments

Comments
 (0)