python tempfile.mkdtemp with everyone permission

I want to create a temporary directory with every one permission to read, write and execute. I also want to be able to run it on both, windows and linux. i have tried tempfile.mkdtemp(), but it is with very limiting permission.

does anyone knows how to do that?

Upvotes: 5

Views: 4834

Answers (1)

richflow
richflow

Reputation: 2144

You want to change permissions with os.chmod:

>>> import tempfile
>>> t = tempfile.mkdtemp()
>>> import os
>>> os.chmod(t, 0o444)
>>> t
'/var/folders/pg/j27n0zds1bq9pzgl9g6bm9yw0000gn/T/tmpgbuhokn7'

In bash:

dr--r--r--    2 me  staff    64 21 Nov 17:48 tmpgbuhokn7

If you want other permissions, read the docs

Upvotes: 4

Related Questions