Check whether given string is a valid Python identifier.

    Note that this excludes language keywords, even though they exhibit
    a general form of an identifier. See also :func:`has_identifier_form`.

    :param s: String to check
    :return: Whether ``s`` is a valid Python identifier

def is_identifier(s):
    """Check whether given string is a valid Python identifier.

    Note that this excludes language keywords, even though they exhibit
    a general form of an identifier. See also :func:`has_identifier_form`.

    :param s: String to check
    :return: Whether ``s`` is a valid Python identifier
    """
    ensure_string(s)

    if not IDENTIFIER_FORM_RE.match(s):
        return False
    if is_keyword(s):
        return False

    # ``None`` is not part of ``keyword.kwlist`` in Python 2.x,
    # so we need to check for it explicitly
    if s == 'None' and not IS_PY3:
        return False

    return True