My python script creates a file if it doesn't exist, reads and writes that file. The script may be run by root (automated) or by the user (refresh request). I need the file to be created with write permission so that in both cases the file can be re-written.
import os
f = os.open('file', os.O_CREAT, 0777)
os.close(f)
but then...
$ ls -l
-rwxr-xr-x 1 pi pi 0 Feb 22 13:51 file
However, this script works and I don't understand the difference:
import os
f = os.open('file', os.O_CREAT)
os.fchmod(f, 0777)
os.close(f)
...and then:
$ ls -l
-rwxrwxrwx 1 pi pi 0 Feb 22 13:54 file