Python module os.chmod(file, 664) does not change the permission to rw-rw-r– but -w–wx—-

Found this on a different forum

If you’re wondering why that leading zero is important, it’s because
permissions are set as an octal integer, and Python automagically
treats any integer with a leading zero as octal. So os.chmod(“file”,
484) (in decimal) would give the same result.

What you are doing is passing 664 which in octal is 1230

In your case you would need

os.chmod("/tmp/test_file", 436)

[Update] Note, for Python 3 you have prefix with 0o (zero oh). E.G, 0o666

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)