Keywords
Python Keywords
Section titled “Python Keywords”Just like natural languages, a computer programming language comprises of a set of predefined words which are called keywords. A prescribed rule of usage for each keyword is called a syntax.
Python 3.x has 33 keywords. Since they have a predefined meaning attached, they cannot be used for any other purpose. The list of Python keywords can be obtained using the following help command in Python shell.
>>>help("keywords")>>>help("keywords")
The following table list all the keywords in Python.
ifeliftryelsewhilelambdafinallybreakforclasscontinueglobalpass
Except for the first three (False, None and True), the other keywords are entirely in lowercase.
Use help() command to know more about each individual keyword. The following will display information on theglobal keyword.
help()``global
>>>help("global")>>>help("global")
Reserved Identifiers
Section titled “Reserved Identifiers”Python built-in classes contains some identifiers that have special meanings. These special identifiers are recognized by the patterns of leading and trailing underscore characters:
>>> 5 * 5 25 >>> _ 25>>> 5 * 5 25 >>> _ 25``__new__()``__init__()``__name__``__main__
>>> __name__ '__main__' >>> __name__ '__main__'