0

I am facing a strange problem, which is that my when I write a file or create a folder from within my Python program, it creates those files and folders with full permissions, while my default user permissions are not like that.

So, my question is, is there a way I can set the permissions from within my Python program, so that it creates all files and folders with some specific permissions.

MetallicPriest
  • 29,191
  • 52
  • 200
  • 356
  • 1
    Does this help? https://stackoverflow.com/q/10291131/113848 – legoscia Jan 21 '20 at 13:47
  • 1
    In [`pathlib`](https://docs.python.org/3/library/pathlib.html) both `Path.mkdir` and `Path.touch` have a `mode` parameter, and in [`os`](https://docs.python.org/3/library/os.html) all of `open`, `mkdir`, `makedirs`, `mkfifo` and `mknod` do too, and `umask` can be used to set the current permissions mask. – jdehesa Jan 21 '20 at 13:55
  • @legoscia. Works like a charm :) – MetallicPriest Jan 21 '20 at 14:21

0 Answers0