Generate a password using random characters from uppercase, lowercase, digits, and symbols

    :param length:                      Length of the password to be generated
    :return:                            The random password

def generate_password(length=16):
    """
    Generate a password using random characters from uppercase, lowercase, digits, and symbols

    :param length:                      Length of the password to be generated
    :return:                            The random password
    """
    chars = string.ascii_letters + string.digits + '!@#$%^&*()_+-=[]{};:,<.>?|'
    modulus = len(chars)
    pchars = os.urandom(16)
    if type(pchars) == str:
        return ''.join(chars[i % modulus] for i in map(ord, pchars))
    else:
        return ''.join(chars[i % modulus] for i in pchars)