'Return a list of groups the user belongs to'

def user_group_membership(self, exclude_primary=True):

    groups = []
    info = self.get_pwd_info()
    for group in grp.getgrall():
        if (self.name in group.gr_mem):
            if (not exclude_primary):
                groups.append(group[0])
            elif (info[3] != group.gr_gid):
                groups.append(group[0])
    return groups
