Tiếp tục phần 1 đã Cách code Python như một lập trình viên chuyên nghiệp, phần 2 sẽ nói về các keyword trong Python.

Khi đặt tên biến (name) trong chương trình Python, cần chú ý không đặt trùng với các keyword trên.

Số lượng keyword rất ít nên cố nhớ và không vi phạm vào.

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

Keywords trong Python có thể xem được qua các lệnh sau:

import keyword
print(keyword.kwlist)
['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']

Ngoài ra còn một số từ khóa là built-in function của Python. Không nên đặt tên trùng với các từ khóa này.

Các từ khóa này có thể tham khảo tại https://docs.python.org/3/library/functions.html

Built-in Functions
abs() dict() help() min() setattr()
all() dir() hex() next() slice()
any() divmod() id() object() sorted()
ascii() enumerate() input() oct() staticmethod()
bin() eval() int() open() str()
bool() exec() isinstance() ord() sum()
bytearray() filter() issubclass() pow() super()
bytes() float() iter() print() tuple()
callable() format() len() property() type()
chr() frozenset() list() range() vars()
classmethod() getattr() locals() repr() zip()
compile() globals() map() reversed() __import__()
complex() hasattr() max() round()  
delattr() hash() memoryview() set()