def _uid2usernames(self): d = collections.defaultdict(list) for u in pwd.getpwall(): d[u.pw_uid].append(u.pw_name) return d