Python requires a statement wherever a block is expected — after a def, if, class and so on. An empty block is a syntax error. pass is a do-nothing statement that satisfies that requirement, letting you stub out code you haven't written yet.
Stubbing out code
def process_payment():pass # TODO: implement later — no syntax error meanwhileclass Order:pass # an empty class you'll flesh outif condition:pass # decide to do nothing here for nowelse:handle()
pass vs continue vs ...
Key takeaways
- 01pass is a no-op that satisfies Python's requirement for a non-empty block.
- 02Use it to stub functions, classes and branches you'll implement later.
- 03Inside loops, prefer continue when you mean "skip this item".
- 04Ellipsis (...) is sometimes used as an equivalent placeholder.
