Suppose you are designing a new class with some methods that you don't want to implement, yet.

class MyClass(object):
    def meth_a(self):
        pass

    def meth_b(self):
        print "I'm meth_b"

If you were to leave out the pass, the code wouldn't run.

You would then get an:

IndentationError: expected an indented block

To summarize, the pass statement does nothing particular, but it can act as a placeholder, as demonstrated here.

Answer from sebastian_oe on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-pass-statement
Python pass Statement - GeeksforGeeks
The pass statement in Python is a placeholder that does nothing when executed.
Published   October 4, 2025
🌐
Python.org
discuss.python.org › python help
Can someone please explain the pass statement? - Python Help - Discussions on Python.org
January 26, 2023 - I’m just wondering what the purpose of the pass statement is and how its used. The answers I’ve found are vague saying it does nothing- so what is it used for? Any examples? Thanks! Dave
Discussions

Unravelling the `pass` statement
omg it literally does nothing.... More on reddit.com
🌐 r/Python
24
283
May 15, 2021
PEP 559 -- Built-in noop()
Whats wrong with pass? :-/ More on reddit.com
🌐 r/Python
23
September 10, 2017
🌐
W3Schools
w3schools.com › python › ref_keyword_pass.asp
Python pass Keyword
Python Examples Python Compiler ... Bootcamp Python Certificate Python Training ... The pass statement is used as a placeholder for future code....
Top answer
1 of 16
522

Suppose you are designing a new class with some methods that you don't want to implement, yet.

class MyClass(object):
    def meth_a(self):
        pass

    def meth_b(self):
        print "I'm meth_b"

If you were to leave out the pass, the code wouldn't run.

You would then get an:

IndentationError: expected an indented block

To summarize, the pass statement does nothing particular, but it can act as a placeholder, as demonstrated here.

2 of 16
264

Python has the syntactical requirement that code blocks (after if, except, def, class etc.) cannot be empty. Empty code blocks are however useful in a variety of different contexts, such as in examples below, which are the most frequent use cases I have seen.

Therefore, if nothing is supposed to happen in a code block, a pass is needed for such a block to not produce an IndentationError. Alternatively, any statement (including just a term to be evaluated, like the Ellipsis literal ... or a string, most often a docstring) can be used, but the pass makes clear that indeed nothing is supposed to happen, and does not need to be actually evaluated and (at least temporarily) stored in memory.

  • Ignoring (all or) a certain type of Exception (example from xml):

     try:
         self.version = "Expat %d.%d.%d" % expat.version_info
     except AttributeError:
         pass # unknown
    

    Note: Ignoring all types of raises, as in the following example from pandas, is generally considered bad practice, because it also catches exceptions that should probably be passed on to the caller, e.g. KeyboardInterrupt or SystemExit (or even HardwareIsOnFireError – How do you know you aren't running on a custom box with specific errors defined, which some calling application would want to know about?).

     try:
         os.unlink(filename_larry)
     except:
         pass
    

    Instead using at least except Error: or in this case preferably except OSError: is considered much better practice. A quick analysis of all Python modules I have installed gave me that more than 10% of all except ...: pass statements catch all exceptions, so it's still a frequent pattern in Python programming.

  • Deriving an exception class that does not add new behaviour (e.g., in SciPy):

     class CompileError(Exception):
         pass
    

    Similarly, classes intended as abstract base class often have an explicit empty __init__ or other methods that subclasses are supposed to derive (e.g., pebl):

     class _BaseSubmittingController(_BaseController):
         def submit(self, tasks): pass
         def retrieve(self, deferred_results): pass
    
  • Testing that code runs properly for a few test values, without caring about the results (from mpmath):

     for x, error in MDNewton(mp, f, (1,-2), verbose=0,
                              norm=lambda x: norm(x, inf)):
         pass
    
  • In class or function definitions, often a docstring is already in place as the obligatory statement to be executed as the only thing in the block. In such cases, the block may contain pass in addition to the docstring in order to say “This is indeed intended to do nothing.”, for example in pebl:

     class ParsingError(Exception):
         """Error encountered while parsing an ill-formed datafile."""
         pass
    
  • In some cases, pass is used as a placeholder to say “This method/class/if-block/... has not been implemented yet, but this will be the place to do it”, although I personally prefer the Ellipsis literal ... in order to strictly differentiate between this and the intentional “no-op” in the previous example. (Note that the Ellipsis literal is a valid expression only in Python 3)

    For example, if I write a model in broad strokes, I might write

     def update_agent(agent):
         ...
    

    where others might have

     def update_agent(agent):
         pass
    

    before

     def time_step(agents):
         for agent in agents:
             update_agent(agent)
    

    as a reminder to fill in the update_agent function at a later point, but run some tests already to see if the rest of the code behaves as intended. (A third option for this case is raise NotImplementedError. This is useful in particular for two cases: Either “This abstract method should be implemented by every subclass, and there isn't a generic way to define it in this base class”, or “This function, with this name, is not yet implemented in this release, but this is what its signature will look like”)

🌐
Tutorialspoint
tutorialspoint.com › python › python_pass_statement.htm
Python - pass Statement
Python pass statement is used when a statement is required syntactically but you do not want any command or code to execute. It is a null which means nothing happens when it executes.
🌐
Programiz
programiz.com › python-programming › pass-statement
Python pass Statement (With Examples)
In Python programming, the pass statement is a null statement which can be used as a placeholder for future code.
🌐
Wiingy
wiingy.com › home › learn › python › pass statement in python
Pass Statement in Python (With Examples)
January 30, 2025 - The pass statement is a way of telling Python that nothing should happen. The pass statement is used in Python programming when you need to have a statement in a code block but you do not want any action to be taken.
Find elsewhere
🌐
DataCamp
datacamp.com › tutorial › python-pass
How to Use the Python pass Statement | DataCamp
July 11, 2024 - The Python pass statement serves as a placeholder in situations where a statement is syntactically necessary, but no actual code is needed. The pass statement is a null operation that returns nothing when executed in a code block.
🌐
W3Schools
w3schools.com › python › python_if_pass.asp
Python Pass Statement
In empty functions or classes that you plan to implement later · During development, you might want to sketch out your program structure before implementing the details. The pass statement allows you to do this without syntax errors. ... age = 16 if age < 18: pass # TODO: Add underage logic later else: print("Access granted") Try it Yourself » · A comment is ignored by Python, but pass is an actual statement that gets executed (though it does nothing).
🌐
LearnDataSci
learndatasci.com › solutions › python-pass
Python pass statement: When, why, and how to use it – LearnDataSci
These statements can be influenced by what are known as control statements, allowing you to govern your code in different ways. The three control statements in Python are pass, continue and break. This article looks specifically at the pass statement. As mentioned previously, pass is usually used as a placeholder for branches, functions, classes.
🌐
Educative
educative.io › answers › what-is-pass-statement-in-python
What is pass statement in Python?
It’s a simple way to tell the interpreter, “I know this is a part of my code, but I'll fill it in later.” In short, the pass statement allows us to complete our code later without causing errors in the meantime. The pass statement in Python is simple and intuitive.
🌐
Python
docs.python.org › 2.0 › ref › pass.html
6.4 The pass statement
It is useful as a placeholder when a statement is required syntactically, but no code needs to be executed, for example: def f(arg): pass # a function that does nothing (yet) class C: pass # a class with no methods (yet) Previous: 6.3.1 Augmented Assignment statements Up: 6. Simple statements Next: 6.5 The del statement · See About this document... for information on suggesting changes.
🌐
Real Python
realpython.com › python-pass
The pass Statement: How to Do Nothing in Python – Real Python
September 25, 2023 - After the for statement is the body of the for loop, which consists of the two indented lines immediately following the colon. In this case, there are two statements in the body that are repeated for each value: ... The statements inside this type of block are technically called a suite in the Python grammar. A suite must include one or more statements. It can’t be empty. To do nothing inside a suite, you can use Python’s special pass statement.
🌐
ACTE
acte.in › home › how and when to use pass in python programming
Pass In Python : Syntax, Usage & Examples | Updated 2026
CyberSecurity Framework and Implementation Article
The primary purpose of pass is to maintain the structure of the code during development, especially when the actual implementation is yet to be written.In Python, the pass statement is a null operation used when a statement is syntactically required but no action is needed. One of best Institute to learn CyberSecurity Framework and Implementation from ACTE . Really impressive model where you can learn technical Skills , Soft Skill and get help to kick start your first Job as well.
Rating: 5 ​
🌐
Analytics Vidhya
analyticsvidhya.com › home › python pass statement
Python pass Statement
January 27, 2025 - In Python, the pass statement is a simple yet powerful tool used as a placeholder in your code. It allows you to create a block of code that does nothing, which can be particularly useful during the development process.
🌐
Programiz PRO
programiz.pro › resources › python-pass
Python pass Statement
December 10, 2024 - This article is a complementary resource to the Learn Python Basics course. The pass statement in Python acts as a placeholder that allows you to create empty functions, loops, or conditional blocks without causing an error.
🌐
Hero Vired
herovired.com › learning-hub › topics › pass-statement-in-python
Pass Statement in Python - What Is It and How to Use It
July 27, 2024 - In this article, we learned about the pass statement in Python. The pass statement is a null statement that can be used as a placeholder for future code. Using a ‘pass’ statement in the program, developers can plan and outline their code ...
🌐
iO Flood
ioflood.com › blog › python-pass
Python 'pass' Statement | Guide (With Examples)
June 7, 2024 - ... In this code, we’ve used a ‘for’ loop to iterate over a range of 5 numbers. Inside the loop, we’ve set a condition: if ‘i’ equals 3, then pass. The ‘pass’ statement here means that Python should do nothing.
🌐
Javatpoint
javatpoint.com › python-pass
Python Pass Statement
python pass - A simple and easy to learn tutorial on various python topics such as loops, strings, lists, dictionary, tuples, date, time, files, functions, modules, methods and exceptions.
🌐
Unstop
unstop.com › home › blog › python pass statement | uses, alternatives & more (+examples)
Python Pass Statement | Uses, Alternatives & More (+Examples)
October 21, 2024 - The pass statement in Python is a placeholder that does nothing when executed. It's used when a statement is syntactically required, but no action is needed.