2

Is there a library which does provide shutil.chown in Python2?

I know that this work around works:

import pwd
import grp
import os

uid = pwd.getpwnam("nobody").pw_uid
gid = grp.getgrnam("nogroup").gr_gid
path = '/tmp/f.txt'
os.chown(path, uid, gid)

Above code from: https://stackoverflow.com/a/5995007/633961

I don't want to use the above work-around, I prefer to reuse.

7
  • why not write your own wrapper to emulate it? The python guys might accept a patch for a new from future thing – chicks Oct 22 '15 at 13:25
  • 1
    @chicks Python2 is a dead end. But I still have some Python2 systems running. I don't want to invest much time into Python2. Python3 already has it. – guettli Oct 22 '15 at 13:28
  • It sounds like you should use python3 then. – chicks Oct 22 '15 at 13:29
  • 1
    @chicks I choose Python3 in all projects where I am able to choose the Python version. In some projects I am just a small sheep and there is no one willing to pay the time which is needed to do the update to Python3. – guettli Oct 22 '15 at 14:00
  • What do you mean you prefer to reuse? – user193661 Oct 24 '15 at 22:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.