O'Reilly logo

The Python Quick Syntax Reference by Gregory Walters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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         ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required