File Permissions

Juho Schultz juho.schultz at helsinki.fi
Fri Mar 10 09:43:15 EST 2006


VJ wrote:
> Hi All
> 
> Basically i want to write into a file .If the permissions are not there
> then print a error message.
> How do i achive this ???
> 
> Thanks,
> VJ
> 

One way would be a try-except block, and leave the permission checking 
error message generation, etc. to the operating system.

try:
     outfile = file(outfilename,"w")
except IOError, errormsg
     print "Could not write to file %s: %s" % (outfilename, errormsg)




More information about the Python-list mailing list