Build a Better Process

Python Reference: Keywords and Built-in Constants

Like when learning a spoken language, some words you don't consciously make an effort to memorize. Through repeated use they become second nature.
  1. Overview - Make a plan to learn Python statement structure.
  2. Keywords - Get a first look at 33 reserved words.
  3. Prioritize - Go a step deeper with keyword context.
  4. Constants - See the 11 reserved words at the Python Interpreter.
  5. Identify keywords - Add syntax highlighting to text editors.
face pic by Paul Alan Davis, CFA
Updated: February 24, 2021
This page helps to distinguish between keywords that are required for beginners and those that can be learned over time.

Outline Back Tip Next

/ factorpad.com / tech / python / reference / python-keywords.html

An ad-free and cookie-free website.

A Guide to Reserved Words in Python


Python Reference

This Python reference offers programmers a quick way to learn Python and also serves as a source for reminders.

While the version documented here is Python 3.5.3, most of this is suitable for other versions of Python 3. Check your version for details.

1. Overview of Keywords and Built-In Constants

Keywords in Python are reserved for specific purposes and should not be used when naming objects. Many keywords are used in statements and create blocks of code.

Built-In Constants refer to words used at the Python Interpreter and have special meaning there.

2. Python Keywords

Below are the 33 reserved keywords in Python 3 that should not be used when naming objects.

Python Keywords in Version 3.5.3
False def if raise
None del import return
True elif in try
and else is while
as except lambda with
assert finally nonlocal yield
break for not  
class from or  
continue global pass  

As noted in the previous reference page, entering help('keywords') at the Python Interpreter will print keywords for your specific version.

3. Keyword Priority and Context

Taking the list of Python keywords a step further, let's categorize them by Priority so you know which ones to memorize first.

The Statement definition column shows whether the keyword is used to define a specific block of code. Included in parentheses is the statement's purpose.

The Included in column shows contexts where the Python keyword may be used. For example, it may be used as a clause in another statement or block type.

An Expanded View of Python Keywords in Version 3.5.3
Keyword Priority Statement definition
Included in
False High -- 1) Boolean operations
None High NoneType class
(null or no value exists)
True High -- 1) Boolean operations
and High -- 1) Control flow statements
2) Membership operations
3) Boolean operations
as Mid -- 1) import statement
2) with statement
3) try statement
assert Mid assert statement
(error handling)
break High -- 1) for statement
2) while statement
3) try statement
class High class definition
(user-defined classes)
continue High -- 1) for statement
2) while statement
3) try statement
def High def definition
(user-defined functions)
del High del statement
(remove objects or values)
elif High -- 1) if statement
else High -- 1) if statement
2) try statement
3) while statement
4) for statement
except Mid -- 1) try statement
finally Mid -- 1) try statement
for High for statement
from High -- 1) import statement
2) yield statement
global Mid global statement
(scope specifications)
if High if statement
(control flow)
import High import statement
(external modules)
in High -- 1) for statement
2) Membership operations
is High -- 1) Comparison operations
2) Membership operations
lambda Low lambda statement
(nameless single-expression function)
nonlocal Mid nonlocal statement
(scope specifications)
not High -- 1) Control flow statements
2) Membership operations
3) Boolean operations
or High -- 1) Control flow statements
2) Membership operations
3) Boolean operations
pass Mid -- 1) def definition
2) class definition
raise Mid -- 1) try statement
return High -- 1) def definition
2) lambda statement
3) try statement
try Mid try statement
(exception handling)
while High while statement
with Mid with statement
(control flow)
yield Low yield statement
(iterator functions)

At the advanced level, when creating coroutines the words await and async become reserved keywords.

4. Built-in Constants

The Built-In Constants below, when typed at the Python Interpreter have special meaning as well and should only be used for their intended purpose.

Built-in Constants in Python 3.5.3
False NotImplemented quit() license
True Elipsis or ... exit() credits
None __debug__ copyright  

5. Text Editors and Syntax Highlighting

A discussion of selecting text editors and integrated development environments (IDEs) is beyond our scope here certainly. The topic can be a minefield. It become a highly personal choice like selecting a tennis racquet or set of golf clubs. It can take years of experimentation before deciding on the best tool for you.

That said, to avoid being innundated with editor and IDE features most beginners are advised to start learning Python right in the Python Interpreter itself, or with a basic text editor pre-packaged with their operating system. Common choices include Notepad on Windows, TextEdit on macOS and nano at the Linux command line.

See List of text editors at Wikipedia if you have yet to select your editor of choice.

Before you memorize Python keywords and constants it is a good idea to either turn on, or select a text editor with a feature called syntax highlighting. This will highlight keywords in a different color automatically based on the file's extension, like .py for Python scripts.

Related Content

What's Next?

Subscribe to our growing YouTube Channel, a companion to this free online educational website.

Outline Back Tip Next

/ factorpad.com / tech / python / reference / python-keywords.html

python keywords
python reserved words
python constants
python examples
python reference
python saved words
python naming rules
python syntax
python interpreter commands
python vocabulary
python documentation

A newly-updated free resource. Connect and refer a friend today.