def get_random_secret(length):
    """ Similar to get_pseudo_random_string, but accepts a length parameter. """
    chars = string.ascii_uppercase + string.ascii_lowercase + string.digits + "~!@#$%^&*()_+"
    return ''.join(secrets.choice(chars) for x in range(length))
 Similar to get_pseudo_random_string, but accepts a length parameter. 
lemur/common/utils.py