Keyword Functions

keyword.iskeyword()

Test whether a string is a reserved keyword for the running interpreter, not merely a soft keyword. Case-sensitive; does not determine whether every nonkeyword is a valid identifier.

Formal Syntax & Structure

python syntaxpython
keyword.iskeyword(s, /)

Parameters & Attributes

NameTypeDescription
sstrCandidate identifier spelling.

Return Value

bool

The bool result described above.

Working Example

Example Snippetpython
import keywordprint(keyword.iskeyword("class"), keyword.iskeyword("match"))
Python Reference