Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Python · Const

pass

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.

How it works

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.

Syntax

pass

Key points

  • The statement consists of the single keyword pass; it takes no arguments.
  • It deliberately performs no operation when execution reaches it.
  • After pass runs, control continues with the surrounding construct's normal flow.
  • Its main role is filling a required statement position without adding behavior.
  • It fits unfinished or intentionally empty bodies where no action is currently needed.
  • A function can use pass as a temporary body while its implementation is pending.
  • A class definition can use pass when it currently has no methods or attributes.

Common mistakes

  • pass does not return a value, skip surrounding code, or provide implicit behavior; it simply completes normally.
  • Use pass only to satisfy syntax when the branch or body intentionally has no action; it is not a substitute for an implementation.

Example: Using pass as a placeholder

def pending_handler(request):
    pass

class Placeholder:
    pass

print("ready")

The function and class bodies are syntactically valid placeholders; executing pass performs no action.

When to use it

Stub a function body

A function interface is defined before its implementation is ready.

Create an empty class

A class is declared as a marker or future extension point without members yet.

Leave a control-flow body empty

A branch or loop body must exist but intentionally takes no action.

Interview questions

QWhat does Python's 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.

QWhy is 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.

QWhat is the syntax of 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 statement
  • while statement
  • function definitions
  • class definitions
  • simple statements

Source: 7. Simple statements. Checked 2026-10-16.