CHAPTER 7

image

Keywords

Keywords are special reserved words that cannot be used as variable names. Keywords will change over time as Python versions change. Below is a short program that will allow you to obtain a list of keywords specific for your version of Python. It is written using Python 3.x syntax, but will work for version 2.7 as well.

Import keywordprint(keyword.kwlist)

List of Python Keywords

Below is a list of Python keywords, in alphabetical order, for version 2.7.1.

and             as               assert          breakclass           continue         def             delelif            else             except          execfinally         ...

Get The Python Quick Syntax Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.