def does_uid_exist(uid): # type: (int) -> bool ''' Returns True if the given OS user id exists, False otherwise. ''' try: pwd.getpwuid(uid) return True except KeyError: return False