Python keywords are the 35 reserved words that form the language's grammar, such as if, for, def, class, return and import. You can't use them as variable or function names. Python 3.10 and later also have a few soft keywords (match, case, _ and, from 3.12, type) that are special only in certain positions.
import keyword
print(len(keyword.kwlist)) # 35 in Python 3.13
print(keyword.iskeyword("print")) # False: print is a built-in functionThe second half of this lesson is a glossary: precise meanings for words used throughout the course and in Python documentation, such as parameter, argument, expression, iterable and mutable. Using them accurately makes documentation, error messages and interview questions much easier to follow. Examples come from a local history archive cataloguing boxes of documents.
Reserved keywords
The full list, grouped by purpose:
| Purpose | Keywords |
|---|---|
| Values | True, False, None |
| Logic and tests | and, or, not, in, is |
| Decisions and loops | if, elif, else, for, while, break, continue, pass |
| Functions | def, return, lambda, yield |
| Classes and scope | class, global, nonlocal, del |
| Errors | try, except, finally, raise, assert |
| Modules | import, from, as |
| Context and async | with, async, await |
import keyword; print(keyword.kwlist) prints the list for your Python version. Using a keyword as a name is a SyntaxError: class = "A" fails, which is why libraries write class_ or cls.
Built-in function names such as print, len, list, input and id are not keywords. Python lets you reassign them, but doing so hides the built-in, so treat them as reserved in practice.
Soft keywords
Soft keywords have a special meaning only in a particular context, and are ordinary names everywhere else. That allowed Python to add new syntax without breaking existing code that used those words as variable names.
| Soft keyword | Special in | Added |
|---|---|---|
match, case | match statements | 3.10 |
_ | wildcard pattern in case _: | 3.10 |
type | type alias statements: type Point = tuple[float, float] | 3.12 |
import re
match = re.search(r"\d+", "Box 14") # still a normal variable name
print(match.group()) # 14keyword.softkwlist lists them, and the list differs between versions: type appears from 3.12. Code written for a newer Python may use them in ways an older interpreter can't parse.
Core vocabulary
These terms describe functions and code structure:
| Term | Meaning | In label_box(6) |
|---|---|---|
| parameter | a name in a function definition | number in def label_box(number): |
| argument | the value passed when calling | 6 |
| return value | what the function hands back | "Archive box 6" |
| expression | code that produces a value | f"Archive box {number}" |
| statement | a complete instruction | return ..., x = 5, if ...: |
| call | running a function with () | label_box(6) |
| binding | associating a name with an object | box = label_box(6) |
A printed message is output, not a return value: print() shows text and returns None. "Parameter" and "argument" are often used loosely in conversation, but error messages use them precisely, for example missing 1 required positional argument: 'number'.
Object vocabulary
These terms describe values and how they behave:
| Term | Meaning | Examples |
|---|---|---|
| object | any value in Python; everything is one | 6, "box", a function |
| type / class | what kind of object it is | int, str, list |
| mutable | can change in place | list, dict, set |
| immutable | can't change; "changes" create new objects | int, str, tuple |
| hashable | usable as a dict key or set member | str, int, tuple of those |
| iterable | can be looped over | list, str, range, files |
| iterator | produces items one by one with next() | iter(list), generators |
| exception | an object signalling an error | ValueError("bad") |
A name (variable) is a label bound to an object, not a box with a fixed type. box = 6 then box = "six" rebinds the same name to an object of a different type. Two names can refer to the same mutable object, which is why changes made through one are visible through the other.
Independent practice and a worked check
Task: explain binding, expression, statement, parameter, argument, iterable, mutation and exception with archive examples. Write each as a short comment beside a line of code that demonstrates it.
boxes = ["letters", "maps"] # binding: the name boxes refers to a list
total = len(boxes) + 1 # expression: len(boxes) + 1 produces 3
def shelf_label(box_id): # parameter: box_id
return f"Shelf {box_id}" # statement: return
print(shelf_label(4)) # argument: 4
for box in boxes: # iterable: the list supplies items
print(box)
boxes.append("photos") # mutation: the same list grows
try:
boxes.index("diaries")
except ValueError as error: # exception: signals the failed search
print("Not found:", error)For the worked check: is print normally a reserved Python keyword? No. It's a built-in function, so keyword.iskeyword("print") returns False.
Reference and next practice
The language reference lists keywords and soft keywords, and the Python glossary defines hundreds of terms. Continue with the standard library essentials and the interview questions lesson. Practise with the Python exercises and Python quiz.
Python Keywords and Glossary Summary
- Reserved keywords: Keywords such as if, class, return and import have defined grammatical roles.
- Soft keywords: Some words have special meaning only in particular grammatical contexts.
- Core vocabulary: An argument is a supplied value, a parameter is a declared input and a return value is a produced result.
- Object vocabulary: Mutable objects can change state, iterables supply traversal and exceptions signal failures.
Python Keywords and Glossary Examples
Each example shows the code, the output it produces and what each part does.
Python Keywords and Glossary in a small program
import keyword
print(keyword.iskeyword("return"))
print(keyword.iskeyword("print"))
def label_box(number):
return f"Archive box {number}"
print(label_box(6))True
False
Archive box 6Line-by-line explanation
- Line 2
returnis a reserved keyword. - Line 3
printis a built-in function, not a keyword. - Lines 4 to 5
numberis a parameter; the function returns a string. - Line 6
6is the argument; the return value is printed.
Vocabulary in action
import keyword
boxes = ["letters", "maps"] # binding a name to a mutable list
catalogue = boxes # a second name for the same object
catalogue.append("photos") # mutation is visible through both names
print(boxes)
def describe(item, prefix="Box"): # item and prefix are parameters
return f"{prefix}: {item}" # an expression producing the return value
labels = [describe(b) for b in boxes] # each b is an argument
print(labels[0])
print(hash("maps") == hash("maps"), isinstance(boxes, list))
print([w for w in ["match", "for", "type", "print"] if keyword.iskeyword(w)])
print([w for w in ["match", "for", "type", "print"] if keyword.issoftkeyword(w)])['letters', 'maps', 'photos']
Box: letters
True True
['for']
['match', 'type']Line-by-line explanation
- Lines 3 to 5
catalogueandboxesname the same list, so the append shows through both. - Lines 8 to 9
itemandprefixare parameters; the f-string is the expression that gives the return value. - Lines 14 to 15
foris a reserved keyword;matchandtypeare soft keywords, andprintis neither.
Common Python Keywords and Glossary Mistakes
Using a keyword as a variable name
class = "Year 9" # SyntaxError
from = "archive" # SyntaxErrorclass_name = "Year 9"
source = "archive"Shadowing a built-in function
list = ["letters", "maps"]
boxes = list(range(3)) # TypeError: 'list' object is not callablebox_list = ["letters", "maps"]
boxes = list(range(3))Built-ins aren't keywords, so Python allows this; the original function is then hidden.
Python Keywords and Glossary in Real Projects
Why precise vocabulary matters
Documentation, error messages, code reviews and job interviews all use this vocabulary. An error such as TypeError: unhashable type: 'list' makes sense immediately once you know what hashable means, and a reviewer's comment "this function mutates its argument" points straight at the bug. Interview questions frequently probe the differences: mutable versus immutable, iterable versus iterator, is versus ==, parameter versus argument.
Editors and linters know the keyword list too: syntax highlighting colours keywords differently, and tools warn when you shadow a built-in. Python's own glossary is a good place to check a term you meet in documentation.
Python Keywords and Glossary FAQ
How many keywords are there in Python?
Python 3.13 has 35 reserved keywords, plus the soft keywords match, case, _ and type. The exact count changes occasionally between versions; len(keyword.kwlist) shows it for the interpreter you're running.
Is print a keyword in Python 3?
No. In Python 3, print is a built-in function. It was a statement keyword in Python 2, which is why old code writes print "Hello" without brackets.
What is the difference between a parameter and an argument?
A parameter is the name listed in a function definition, such as name in def greet(name):. An argument is the actual value passed in a call, such as "Ada" in greet("Ada").
Are True, False and None keywords?
Yes. They are reserved keywords with capital first letters, so you can't assign to them. true, false and none in lower case are ordinary names and cause NameError unless you define them.
What is a soft keyword in Python?
A word that acts as a keyword only in a specific context. match and case are keywords inside a match statement but can still be used as variable names elsewhere, which kept older code working when pattern matching was added in Python 3.10.
Python Keywords and Glossary Exercises
Answer each one and check it instantly. If you get stuck, open the hint before the answer.
Is print normally a reserved Python keyword?
Which review concern is valid for Python keywords and glossary?
Python Keywords and Glossary Quiz
2 questions to check what you learned.
Is print normally a reserved Python keyword?
- Yes
- No
- Python ignores the distinction
Which statement correctly describes core vocabulary?
- An argument is a supplied value, a parameter is a declared input and a return value is a produced result.
- Only the example output matters, not the rule
- Every operation has the same behavior