Attention when os.mkdir in Python

(It is a memorandum)

When creating a directory in Python os.mkdir(path,[mode]) http://docs.python.jp/2.7/library/os.html#os.mkdir

I use

mkdir_NG_0777



os.mkdir("hoge",0777)

Even though the directory is not created with permission 0777. As stated in the manual, umask is applied, so it will behave as described in the following article. (That is, the second parameter is not the permission setting!)

reference: Permission (umask) when creating a Linux file directory http://qiita.com/yuki2006@github/items/3774bf765eb5ef7deabc

In other words, you have to do the following.

mkdir_OK_0777



os.mkdir("hoge")
os.chmod("hoge",0777)

It feels a bit crappy (redundant), but what about it? .. (Please let me know if there is a good way.

Recommended Posts

Attention when os.mkdir in Python
Precautions when using pit in Python
When using regular expressions in Python
When writing a program in Python
Quadtree in Python --2
Python in optimization
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
SendKeys in Python
Create ScriptableObject in Python when building ADX2
Precautions when pickling a function in python
Epoch in Python
Discord in Python
Sudoku in Python
DCI in Python
quicksort in python
nCr in python
N-Gram in Python
Programming in python
When looking at memory usage in Python 3
Constant in python
Lifegame in Python.
FizzBuzz in Python
Sqlite in python
StepAIC in Python
N-gram in python
LINE-Bot [0] in Python
Csv in python
Disassemble in Python
Reflection in Python
Constant in python
nCr in Python.
format in python
Scons in Python3
Puyo Puyo in python
python in virtualenv
PPAP in Python
Quad-tree in Python
Reflection in Python
Chemistry in Python
Hashable in python
DirectLiNGAM in Python
LiNGAM in Python
Flatten in python
flatten in python
[Tips] Easy-to-read writing when connecting functions in Python
When codec can't decode byte appears in python
When I try matplotlib in Python, it says'cairo.Context'
Precautions when dealing with control structures in Python 2.6
Note on encoding when LANG = C in Python
Character encoding when dealing with files in Python 3
Split files when writing vim plugin in python
[Question] What happens when I use% in python?
Error when trying to install psycopg2 in Python
Behavior when saving python datetime object in MongoDB
Solution when module'XXX' has no attribute'XXX' in Python
Use pydantic when reading environment variables in Python
Sorted list in Python
Daily AtCoder # 36 in Python
Clustering text in Python