how to find the owner of a file or directory in python

I’m not really much of a python guy, but I was able to whip this up:

from os import stat
from pwd import getpwuid

def find_owner(filename):
    return getpwuid(stat(filename).st_uid).pw_name

Leave a Comment