[i]Learn· More Control Flow Tools
pass Statements
The pass statement does nothing. It can be used when a statement is
required syntactically but the program requires no action. For example:
>>> while True:
... pass # Busy-wait for keyboard interrupt (Ctrl+C)
...
This is commonly used for creating minimal classes:
>>> class MyEmptyClass:
... pass
...
Another place pass can be used is as a place-holder for a function or
conditional body when you are working on new code, allowing you to keep thinking
at a more abstract level. The pass is silently ignored:
>>> def initlog(*args):
... pass # Remember to implement this!
...
For this last case, many people use the ellipsis literal ... instead of
pass. This use has no special meaning to Python, and is not part of
the language definition (you could use any constant expression here), but
... is used conventionally as a placeholder body as well.
See The Ellipsis Object.
example 1 of 2
[>_]Terminal
Output appears here when you press Run.
$ ▌