keyword - Keywords (from "Grammar/python.gram")
| Use Case | Command | Description |
|---|---|---|
| Check if a string is a keyword | import keyword; keyword.iskeyword('if') | Returns True if the string is a hard keyword |
| Check if a string is a soft keyword | keyword.issoftkeyword('match') | Returns True for contextβdependent soft keywords |
| Get all hard keywords | keyword.kwlist | List of strings for all Python hard keywords |
| Get all soft keywords | keyword.softkwlist | List of strings for all Python soft keywords |
https://docs.python.org/3.10/library/keyword.html
The following documentation is automatically generated from the Python source files. It may be incomplete, incorrect or include features that are considered implementation detail and may vary between Python implementations. When in doubt, consult the module reference at the location listed above.
This file is automatically generated; please don't muck it up!
To update the symbols in this file, 'cd' to the top directory of the python source tree and run:
PYTHONPATH=Tools/peg_generator python3 -m pegen.keywordgen \
Grammar/python.gram \
Grammar/Tokens \
Lib/keyword.py
Alternatively, you can run:
make regen-keyword
iskeyword β frozenset membership test: x.__contains__(y) <==> y in x.issoftkeyword β frozenset membership test: x.__contains__(y) <==> y in x.__all__ = ['iskeyword', 'issoftkeyword', 'kwlist', 'softkwlist']kwlist = ['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'aw...softkwlist = ['_', 'case', 'match']/usr/lib/python3.10/keyword.py
Generated by phpman v4.9.27 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-18 13:20 @216.73.216.114
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format