There are a variety of use cases for pass, though their number has dwindled over time as some language constructs have grown ways to omit previously mandatory sections. A common example is when you’re prototyping a program and you want to sketch out a high-level outline but leave some function c… Answer from fungi on discuss.python.org
🌐
Trey Hunner
treyhunner.com › 2020 › 01 › passing-functions-as-arguments
Passing a function as an argument to another function in Python
January 14, 2020 - And we can pass the function into itself (yes this is weird), which converts it to a string here: >>> greet(greet) Hello <function greet at 0x7f93416be8b0>! There are actually quite a few functions built-in to Python that are specifically meant to accept other functions as arguments.
🌐
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

python - How to use "pass" statement? - Stack Overflow
Breadcrumb trail to follow regarding Ellipsis mail.python.org/pipermail/python-3000/2008-January/011793.html 2020-10-28T10:06:19.7Z+00:00 ... Save this answer. ... Show activity on this post. Besides its use as a placeholder for unimplemented functions, pass can be useful in filling out an ... More on stackoverflow.com
🌐 stackoverflow.com
How do I pass a method as a parameter in Python - Stack Overflow
How does using a function (callback) as an argument to another function work in Python? (11 answers) Closed 3 years ago. Is it possible to pass a method as a parameter to a method? More on stackoverflow.com
🌐 stackoverflow.com
Pass a function into another function as an argument, with some but not all of the arguments?
See "partial" from the functools module A partial function is pretty much a function with some of its arguments filled in More on reddit.com
🌐 r/learnpython
7
2
October 31, 2022
Python - Passing a function into another function - Stack Overflow
I am solving a puzzle using python and depending on which puzzle I am solving I will have to use a special set of rules. How can I pass a function into another function in Python? Example def Game( More on stackoverflow.com
🌐 stackoverflow.com
🌐
W3Schools
w3schools.com › python › ref_keyword_pass.asp
Python pass Keyword
The pass statement is used as a placeholder for future code. When the pass statement is executed, nothing happens, but you avoid getting an error when empty code is not allowed. Empty code is not allowed in loops, function definitions, class ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › passing-function-as-an-argument-in-python
Passing Function as an Argument in Python - GeeksforGeeks
June 5, 2026 - Example: Here, a function is passed as an argument to another function to convert text into uppercase. Python · def process(func, text): return func(text) def uppercase(text): return text.upper() print(process(uppercase, "hello")) Output · HELLO · Explanation: uppercase() function is passed to process().
Top answer
1 of 16
523

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
263

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”)

🌐
GeeksforGeeks
geeksforgeeks.org › python › python-pass-statement
Python pass Statement - GeeksforGeeks
The pass statement in Python is a placeholder that does nothing when executed. It is used to keep code blocks valid where a statement is required but no logic is needed yet. Examples situations where pass is used are empty functions, classes, ...
Published: March 27, 2026
Top answer
1 of 9
347

Yes it is, just use the name of the method, as you have written. Methods and functions are objects in Python, just like anything else, and you can pass them around the way you do variables. In fact, you can think about a method (or function) as a variable whose value is the actual callable code object.

Since you asked about methods, I'm using methods in the following examples, but note that everything below applies identically to functions (except without the self parameter).

To call a passed method or function, you just use the name it's bound to in the same way you would use the method's (or function's) regular name:

def method1(self):
    return 'hello world'

def method2(self, methodToRun):
    result = methodToRun()
    return result

obj.method2(obj.method1)

Note: I believe a __call__() method does exist, i.e. you could technically do methodToRun.__call__(), but you probably should never do so explicitly. __call__() is meant to be implemented, not to be invoked from your own code.

If you wanted method1 to be called with arguments, then things get a little bit more complicated. method2 has to be written with a bit of information about how to pass arguments to method1, and it needs to get values for those arguments from somewhere. For instance, if method1 is supposed to take one argument:

def method1(self, spam):
    return 'hello ' + str(spam)

then you could write method2 to call it with one argument that gets passed in:

def method2(self, methodToRun, spam_value):
    return methodToRun(spam_value)

or with an argument that it computes itself:

def method2(self, methodToRun):
    spam_value = compute_some_value()
    return methodToRun(spam_value)

You can expand this to other combinations of values passed in and values computed, like

def method1(self, spam, ham):
    return 'hello ' + str(spam) + ' and ' + str(ham)

def method2(self, methodToRun, ham_value):
    spam_value = compute_some_value()
    return methodToRun(spam_value, ham_value)

or even with keyword arguments

def method2(self, methodToRun, ham_value):
    spam_value = compute_some_value()
    return methodToRun(spam_value, ham=ham_value)

If you don't know, when writing method2, what arguments methodToRun is going to take, you can also use argument unpacking to call it in a generic way:

def method1(self, spam, ham):
    return 'hello ' + str(spam) + ' and ' + str(ham)

def method2(self, methodToRun, positional_arguments, keyword_arguments):
    return methodToRun(*positional_arguments, **keyword_arguments)

obj.method2(obj.method1, ['spam'], {'ham': 'ham'})

In this case positional_arguments needs to be a list or tuple or similar, and keyword_arguments is a dict or similar. In method2 you can modify positional_arguments and keyword_arguments (e.g. to add or remove certain arguments or change the values) before you call method1.

2 of 9
42

Yes it is possible. Just call it:

class Foo(object):
    def method1(self):
        pass
    def method2(self, method):
        return method()

foo = Foo()
foo.method2(foo.method1)
Find elsewhere
🌐
LearnDataSci
learndatasci.com › solutions › python-pass
Python pass statement: When, why, and how to use it – LearnDataSci
pass is a great way of exercising more controls over our scripts, hence why it's called a control statement. Whenever pass is triggered, Python will skip over it, not doing anything. This functionality is beneficial for testing and debugging, as we can use pass as a placeholder.
🌐
AskPython
askpython.com › python › examples › pass-function-as-argument
Python: How to pass a function as an argument? - AskPython
July 11, 2021 - The functions which are defined inside a specific class we call them methods in Python. First-class objects are those objects which are treated uniformly throughout the program. It means the first-class objects can be stored in a variable, passed as an argument to a function, or used in control statements.
🌐
DataCamp
datacamp.com › tutorial › python-pass
How to Use the Python pass Statement | DataCamp
July 11, 2024 - The simplest way to use the pass statement in Python is to place it in any code block that you want to leave empty. For example, you can place the pass statement in a function to avoid errors that would otherwise occur when you leave it empty.
🌐
Reddit
reddit.com › r/learnpython › pass a function into another function as an argument, with some but not all of the arguments?
r/learnpython on Reddit: Pass a function into another function as an argument, with some but not all of the arguments?
October 31, 2022 -

Hello, I am new to python, and am trying to learn as I go for my machine learning class. In order to make some of my assignment work, I need to be able to pass a function in as an argument to another function, but have some of the arguments already filled out.

So for example, let’s say I wanted to pass the function “foo” to use in a function “bar”. Lets assume that foo takes the arguments a, b, and c. I could write

bar(foo)

but in order to call foo, I would need a, b and c in bar.

alternatively, I could write

bar(foo(a, b, c))

but this is going to pass in as a value, and I need all 3 values.

Let’s say I have a and b to pass in, but c is calculated within bar. Is there a way to do this so I can give bar a and b, but not c?

edit: I figured it out! He just wanted me to create a lambda function that passes the arguments into the function, and then pass that lambda as the argument.

🌐
Python Morsels
pythonmorsels.com › passing-functions-arguments-other-functions
Passing functions as arguments to other functions - Python Morsels
August 3, 2026 - So this get_two function is assuming that func points to a function object or some other callable object (anything that you can call by putting parentheses after it). In Python you can pass function objects in to other functions.
🌐
W3Schools
w3schools.com › python › gloss_python_function_pass.asp
Python Function Pass
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Training ... function definitions cannot be empty, but if you for some reason have a function definition with no content, put in the pass statement to avoid getting an error.
🌐
Programiz
programiz.com › python-programming › pass-statement
Python pass Statement (With Examples)
In Python, pass is a null statement and it does nothing when executed. Despite not doing anything, pass does have a purpose...In such cases, we can use the pass statement as a placeholder. For example,
🌐
Simplilearn
simplilearn.com › home › resources › software development › what is pass in python and usage of pass function in python
What Is Pass in Python and Usage of Pass Function in Python
October 4, 2022 - Pass in python is a null statement used as a placeholder for future code. Read this tutorial to learn all about pass function and it's usage in python!
Address: 5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
Tutorials Class
tutorialsclass.com › home › learn › python tutorial › pass function as an argument in python
Pass function as an argument in Python with Examples - Tutorials Class
August 27, 2020 - def show(text): return text.upper() def display(text): return text.lower() def meet(func): # storing the function in a variable greeting = func("This is created by a function passed as an argument.") print(greeting) meet(show) meet(display)
🌐
Python
docs.python.org › 2.0 › ref › pass.html
6.4 The pass statement
def f(arg): pass # a function that does nothing (yet) class C: pass # a class with no methods (yet)
🌐
Real Python
realpython.com › ref › keywords › pass
pass | Python Keywords – Real Python
A placeholder statement that allows you to write syntactically correct code without executing any operations.
🌐
Python Guides
pythonguides.com › python-pass-function
How To Use The Python Pass Function?
March 19, 2025 - The pass statement in Python is a placeholder that signifies that a particular code block is empty or yet to be written. It is used when you need to define a function, class, or loop without providing any implementation details.