Stub a function body
A function interface is defined before its implementation is ready.
Python · Const
pass is Python's no-op statement. It supplies a syntactically required statement when a function, class, or other body intentionally has nothing to execute.
pass is a statement that performs no operation. Use it where Python requires a statement, such as an unfinished function, class, conditional branch, or loop body, while intentionally leaving that body without behavior.
passpass; it takes no arguments.pass runs, control continues with the surrounding construct's normal flow.pass as a temporary body while its implementation is pending.pass when it currently has no methods or attributes.pass does not return a value, skip surrounding code, or provide implicit behavior; it simply completes normally.pass only to satisfy syntax when the branch or body intentionally has no action; it is not a substitute for an implementation.def pending_handler(request):
pass
class Placeholder:
pass
print("ready")The function and class bodies are syntactically valid placeholders; executing pass performs no action.
A function interface is defined before its implementation is ready.
A class is declared as a marker or future extension point without members yet.
A branch or loop body must exist but intentionally takes no action.
pass statement do?pass is a null operation statement. Execution reaches it and continues without performing an action.
Follow-up: How would you represent an intentionally empty function body? Use pass as the function's indented statement, unless a meaningful implementation is available.
pass useful in a function or class definition?A compound statement body cannot be empty, so pass supplies the required statement while leaving the body behaviorless. Typical cases include placeholder functions and classes.
Follow-up: What happens if the placeholder is removed? Python raises a syntax error because the required indented suite has no statement.
pass, and where can it appear?Its syntax is simply pass. It is a simple statement and can appear wherever a statement is syntactically required, including a conditional or loop body.
Follow-up: Does pass terminate a loop or function? No; it only does nothing at that point, so normal control flow proceeds afterward.
if statementwhile statementfunction definitionsclass definitionssimple statements