print(os.access('sample.txt', os.R_OK)) # Output False f = open("sample.txt", "x") #create the file #check again print(os.access('sample.txt', os.R_OK)) # Output True