DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk2 min

How to Use Python’s `pass` Statement

Python’s `pass` statement is a no-op for places where syntax requires a statement but no action is intended. See examples and common distinctions.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Python’s pass statement when a block of code must contain a statement but you intentionally want it to do nothing. Despite the common wording in this topic, pass is not a function: you do not call it with parentheses or expect it to return a value. Python’s Language Reference defines it as a null operation—when executed, nothing happens.

What pass does

Python syntax requires a body after headers such as def, class, and if. If you want one of those bodies to be empty for now—or deliberately have no action there—write pass as its indented statement. The Python Language Reference describes pass as a null operation.

How to use pass

Place it on its own indented line wherever Python requires a statement and no action is intended:

def not_implemented_yet():
    pass

class Marker:
    pass

if condition:
    pass
else:
    handle_case()

The function and class bodies above are intentionally empty. In the conditional, Python does nothing when condition is true and calls handle_case() when it is false. A function with no explicit return statement returns None when called; that is ordinary function behavior, not a special result produced by pass.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When it is useful

  • As a temporary placeholder: Put pass in a function or branch whose intended behavior you have not implemented yet, so the surrounding code remains syntactically valid. Replace it with the intended statements when ready.
  • For a deliberately empty body: Use it when an empty function, class, or conditional branch is intentional. If you do not want an empty body, write the action the program should take instead.

pass is not a loop-control statement

pass does not skip to the next loop iteration or exit a loop; it simply does nothing at the point where it appears. Use continue when you want to move to the next iteration, and break when you want to leave the loop.

The Python tutorial also gives while True: pass as an example of a loop that can be interrupted with Ctrl+C. Since the loop contains no waiting operation or useful work, it continuously repeats; it is an illustration of the statement, not a useful general-purpose waiting pattern.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

pass and ... are different

The ellipsis literal ... is an expression, while pass is a statement. Python’s tutorial notes that using ... as a placeholder body is a convention, not a special placeholder meaning built into the language. Use pass when you want the explicit no-op statement; do not assume the two constructs have identical roles.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.