changing a file's permissions

Max Erickson maxerickson at gmail.com
Mon Oct 2 15:42:20 CEST 2006


James <oscartheduck at gmail.com> wrote:
> ------=_Part_63041_761240.1159752399799
> I'm writing a script in linux to excercise my python skills and
> have encountered a minor issue.
> 
> Writing the script and creating an ouput file was simple enough
> and didn't take too long. However, I don't have permissions to
> execute the file by default. Now, I could simply chmod 755 the
> sucker and have done with it, but I want to apply the permissions
> within the python script if I can. 
> 
> So my question is: how does one change a file's permissions
> inside of python?
> 
> James
> 

Assuming you want to operate on the output file:

import os
os.chmod(path, 755)


Hope this helps,

max




More information about the Python-list mailing list