Retrieving Python Keywords

Glazner yoavglazner at
Mon Apr 11 15:27:50 CEST 2011

On Apr 10, 4:28 am, candide <cand... at free.invalid> wrote:
> Python is very good at introspection, so I was wondering if Python (2.7)
> provides any feature to retrieve the list of its keywords (and, as,
> assert, break, ...).

>>> import keyword
>>> keyword.kwlist
['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del',
'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global',
'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print',
'raise', 'return', 'try', 'while', 'with', 'yield']

More information about the Python-list mailing list