file manipulation and write permission

Jarkko Torppa torppa at polykoira.megabaud.fi
Tue Mar 21 14:35:52 CET 2000


In article <8b7etk$tr5$1 at nnrp1.deja.com>, tiddlerdeja at my-deja.com wrote:
>I trying to manipulate a whole load of files. However I don't have
>write permission on all the files (I do have ownership of them).
>
>Can some tell me how I make a file writeable in a Python script?

You want os.chmod()

something like

import os,stat
def mkwrite(fp):
    os.chmod(fp,os.stat(fp)[stat.ST_MODE] | stat.S_IRWXU)

should work, not sure if stat.S_IRWXU is allways defined.

>A solution that would work in JPython1.1 would also be great!

Dunno about that, but I would try that same snippet first.

-- 
 Jarkko Torppa                torppa at staff.megabaud.fi
  Megabaud Internet-palvelut



More information about the Python-list mailing list