Python keywords

Alex Martelli aleax at mac.com
Fri Apr 27 01:15:48 EDT 2007


gtb <goodTweetieBird at hotmail.com> wrote:

> Have done some searching but have not found a place where I can look
> up python keywords.

>>> 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']

call help(kw) from an interpreter prompt for any one of these values for
more information.  E.g.,

>>> help('and')

will give you section 5.1 (Boolean operations), all the way to
help('yield') giving 6.8 (The yield statement).  Some of the keywords
have no specific info, e.g. help('as') will not be very informative:-).


Alex



More information about the Python-list mailing list