def _getgroups(uid):
 result = []
 pwent = pwd.getpwuid(uid)
 result.append(pwent.pw_gid)
 for grent in grp.getgrall():
  if (pwent.pw_name in grent.gr_mem):
   result.append(grent.gr_gid)
 return result

def _getgroups ( uid ) : result = [ ] pwent = pwd . getpwuid ( uid ) result . append ( pwent . pw_gid ) for grent in grp . getgrall ( ) : if ( pwent . pw_name in grent . gr_mem ) : result . append ( grent . gr_gid ) return result
return the primary and supplementary groups for the given uid .