You can use the
library function https://docs.python.org/release/2.6.6/library/os.html#os.access like the Linux
access library function for C.
It returns True if access is allowed, False if not.
For readable and writable, you can test file
mode set to:
Value to include in the mode parameter of access() to test the readability of path.
Value to include in the mode parameter of access() to test the writability of path.