There is one more restriction on identifier names. The Python language reserves a small set of keywords that designate special language functionality. No object can have the same name as a reserved word.
In Python 3.6, there are 33 reserved keywords:
| Python Keywords |
|||
|---|---|---|---|
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 |
You can see this list any time by typing help("keywords") to the Python interpreter. Reserved words are case-sensitive and must be used exactly as shown. They are all entirely lowercase, except for False, None, and True.

John DB on Dec. 11, 2019
Maybe some commentary about this?
It seems to me, a bigger problem with keyword clashes is not the small fixed list of 36 items above, but scenarios like this:
Suppose I have a bunch of working code, including snippets copied from StackOverflow:
In the next dev cycle, I add more code almost identical to that which works above, eg:
But… BOOM!
So… how can I find out about “almost keywords” like str which can suddenly become keywords (or keyword-like) with inadvertent use – thus turning my erstwhile “stable code” into a walking time-bomb?