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
| Name | Type | Description |
|---|---|---|
| s | str | Candidate identifier spelling. |
Return Value
bool
The bool result described above.
Working Example
Example Snippetpython
import keywordprint(keyword.iskeyword("class"), keyword.iskeyword("match"))