Chmod to a group only

"Martin v. Löwis" martin at v.loewis.de
Tue Dec 2 00:53:31 CET 2008


>> How to chmod a file to: o-rwx ? (to change only the others mode)
> I have tried:
> 
> mode = os.stat(fname).st_mode
> os.chmod(fname, mode | stat.S_IRWXO) => Changes to o+rwx

Close. Try

os.chmod(fname, mode & ~stat.S_IRWXO)

Regards,
Martin



More information about the Python-list mailing list