Is there any python functions such as:
filename = "a.txt"
if is_open(filename) and open_status(filename)=='w':
print filename," is open for writing"
This is not quite what you want, since it just tests whether a given file is write-able. But in case it's helpful:
import os
filename = "a.txt"
if not os.access(filename, os.W_OK):
print "Write access not permitted on %s" % filename
(I'm not aware of any platform-independent way to do what you ask)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With