def _random_password(length=DEFAULT_LENGTH, chars=C.DEFAULT_PASSWORD_CHARS):
 assert isinstance(chars, text_type), ('%s (%s) is not a text_type' % (chars, type(chars)))
 random_generator = random.SystemRandom()
 password = []
 while (len(password) < length):
  new_char = random_generator.choice(chars)
  password.append(new_char)
 return u''.join(password)

def _random_password ( length = DEFAULT_LENGTH , chars = C . DEFAULT_PASSWORD_CHARS ) : assert isinstance ( chars , text_type ) , ( '%s (%s) is not a text_type' % ( chars , type ( chars ) ) ) random_generator = random . SystemRandom ( ) password = [ ] while ( len ( password ) < length ) : new_char = random_generator . choice ( chars ) password . append ( new_char ) return u'' . join ( password )
return a random password string of length containing only chars :kwarg length: the number of characters in the new password .