def _validate_username(username):
 if (not isinstance(username, basestring)):
  raise AccountUsernameInvalid(u'Username must be a string')
 if (len(username) < USERNAME_MIN_LENGTH):
  raise AccountUsernameInvalid(u"Username '{username}' must be at least {min} characters long".format(username=username, min=USERNAME_MIN_LENGTH))
 if (len(username) > USERNAME_MAX_LENGTH):
  raise AccountUsernameInvalid(u"Username '{username}' must be at most {max} characters long".format(username=username, max=USERNAME_MAX_LENGTH))
 try:
  validate_slug(username)
 except ValidationError:
  raise AccountUsernameInvalid(u"Username '{username}' must contain only A-Z, a-z, 0-9, -, or _ characters")

def _validate_username ( username ) : if ( not isinstance ( username , basestring ) ) : raise AccountUsernameInvalid ( u'Username must be a string' ) if ( len ( username ) < USERNAME_MIN_LENGTH ) : raise AccountUsernameInvalid ( u"Username '{username}' must be at least {min} characters long" . format ( username = username , min = USERNAME_MIN_LENGTH ) ) if ( len ( username ) > USERNAME_MAX_LENGTH ) : raise AccountUsernameInvalid ( u"Username '{username}' must be at most {max} characters long" . format ( username = username , max = USERNAME_MAX_LENGTH ) ) try : validate_slug ( username ) except ValidationError : raise AccountUsernameInvalid ( u"Username '{username}' must contain only A-Z, a-z, 0-9, -, or _ characters" )
validate the username .