def check_username(value): if value not in {x[0] for x in pwd.getpwall()}: raise ValueError('%s is not a valid user' % value) return value