def valid_username(user):
 if (not isinstance(user, string_types)):
  return False
 if (len(user) > 32):
  return False
 return (VALID_USERNAME.match(user) is not None)

def valid_username ( user ) : if ( not isinstance ( user , string_types ) ) : return False if ( len ( user ) > 32 ) : return False return ( VALID_USERNAME . match ( user ) is not None )
validates a username based on the guidelines in useradd(8) .