all Python 3astterm
ast.Pass
statements
Node for the pass statement; it has no fields and stands for an empty block body.
Syntax
ast.Pass()
An empty body can also be written with an ellipsis, but ... is Expr(Constant(Ellipsis)), not Pass, so counting stubs by Pass misses them. The reverse matters too: when a NodeTransformer removes every statement of a block, the body becomes an empty list and compile() rejects it, so insert an ast.Pass().
Examples
import ast
for src in ('pass', '...'):
print(type(ast.parse(src).body[0]).__name__) # → Pass / Expr
See also
Open in the full glossarydocs.python.orgReport an inaccuracy