I want to create a file from within a python script that is executable.
import os import stat os.chmod(\'somefile\', stat.S_IEXEC)
it appea
If you're using Python 3.4+, you can use the standard library's convenient pathlib.
Its Path class has built-in chmod and stat methods.
from pathlib import Path import stat f = Path("/path/to/file.txt") f.chmod(f.stat().st_mode | stat.S_IEXEC)