Quantcast
Viewing latest article 35
Browse Latest Browse All 47

Answer by zgoda for How do I check whether a file exists without exceptions?

Additionally, os.access():

if os.access("myfile", os.R_OK):    with open("myfile") as fp:        return fp.read()

Being R_OK, W_OK, and X_OK the flags to test for permissions (doc).


Viewing latest article 35
Browse Latest Browse All 47

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>