Do you want to do a capability check with `os.access('/system/whatever', os.W_OK)` instead?