Version: 1.1.0
Simple statements
Simple statements fit on one logical line: assignment, a call used for effect, return, raise, break, continue, and pass.
Essentials
- Assignment can unpack tuples when the shapes match.
returnends the function. The value must match the declared type.raiserequires the function to be markedraises.passis an empty statement, useful in a stub.- Imports are also simple statements and usually sit at the top of the file.
Example
def clamp(n: Int) -> Int:
if n < 0:
return 0
return n
Keep in mind
A line break ends the statement unless the line is inside parentheses or a similar grouping.