def _username2supgids(self): d = collections.defaultdict(list) for g in grp.getgrall(): for u in g.gr_mem: d[u].append(g.gr_gid) return d