Is current user member of group www-data ?

Updated Gribouillis 0 Tallied Votes 221 Views Share

The title says it all.

# python 2 or 3, linux only
# AUTHOR: Gribouillis for the python forum at
import grp
import os
import pwd

if pwd.getpwuid(os.getuid()).pw_name in grp.getgrnam('www-data').gr_mem:
	print("current user is a member of group www-data")