Next / Previous / Contents / TCC Help System / NM Tech homepage

12. Python statements

Here is a complete list of all the Python statement types. In each case but one, the keyword shown in the first column appears at the beginning of the statement. The exception is the Python assignment statement: any line containing “=” is considered an assignment statement. A single “=” is not an operator in Python; it cannot be embedded in an expression as in some other languages such as C.

=Assignment. See Section 13.1, “Assignment”.
assertAssertion facility. See Section 13.2, “The assert statement”.
breakBreak out of a loop. See Section 14.5, “The break statement”.
classDefine a new class of objects. See Section 17, “Create your own types: The class construct”.
continueGo to the top of a loop. See Section 14.6, “The continue statement”.
defDefine a function. See Section 16, “Defining and calling functions”.
delDelete a variable or part of an object. See Section 13.3, “The del statement”.
elifSee Section 14.2, “The if construct: choice”.
elseSee Section 14.2, “The if construct: choice”.
exceptSee Section 14.7, “The try construct: catching exceptions”.
execDynamically execute Python code. See Section 13.4, “The exec statement”.
finallySee Section 14.7, “The try construct: catching exceptions”.
forIterate over the members of a sequence. See Section 14.3, “The for construct: iteration”.
fromImport names from a module. See Section 13.5, “The from statement”.
globalUse a global variable. See Section 13.6, “The global statement”.
ifConditional branching. See Section 14.2, “The if construct: choice”.
importImport an external module. See Section 13.7, “The import statement”.
passA placeholder, no-operation statement. See Section 13.8, “The pass statement”.
printDisplay values to output. See Section 13.9, “The print statement”.
raiseRaise an exception. See Section 14.8, “The raise statement: throwing exceptions”.
returnSee Section 16.2, “return: Return the result of a function”.
tryAnticipate possible exceptions. See Section 14.7, “The try construct: catching exceptions”.
whileRepeat a group of statements. See Section 14.4, “The while construct: looping”.
yieldReturn one of a sequence of values from a generator. See Section 18.2, “Generators”.