Reputation:
In Python, we have things like if
, elif
, else
, break
, continue
, pass
, etc. For want of a better word, I'll call them special instructions.
What type are they? If I do something like type(pass)
I get a SyntaxError
.
Upvotes: 1
Views: 110
Reputation: 402844
According to documentation, the terminology you're looking for is "Keywords".
2.3.1. Keywords
The following identifiers are used as reserved words, or keywords of the language, and cannot be used as ordinary identifiers. They must be spelled exactly as written here:
False class finally is return None continue for lambda try True def from nonlocal while and del global not with as elif if or yield assert else import pass break except in raise
These are language constructs. They are part of the language's grammar and syntax, and not objects. The interpreter treats these differently. As such, they are not associated with a type
, as objects typically are.
If, for any reason, you want to know whether a word is a python keyword (aka, reserved word), you can import the keyword
module and test -
import keyword
keyword.iskeyword('if')
True
Upvotes: 9