What is the most efficient way to create a folder with permissions in python (vs. running bash/shell commands)?
I'm converting some bash/shell scripts to Python. I'd like to only create a directory/folder on a CentOS system if it doesn't exist already and then set 777 permissions on it.
I can easily do this with one command in bash:
mkdir -m 777 "/PATH/TO/DIRECTORY/GOES/HERE";
Right now i'm running this command as a subprocess in python, but I was wondering if there was a cleaner, faster, and/or more efficient way of doing it?
Any help or even hits will be appreciated! :)
You can set the permissions directly when using os.mkdir:
mkdir(...) mkdir(path [, mode=0777]) Create a directory.