# python 2 or 3, linux only
# AUTHOR: Gribouillis for the python forum at www.daniweb.com
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")
The article starter has earned a lot of community kudos, and such articles offer a bounty for quality replies.