Do you mean this?

def perform(fun, *args):
    fun(*args)

def action1(args):
    # something

def action2(args):
    # something

perform(action1)
perform(action2, p)
perform(action3, p, r)
Answer from S.Lott on Stack Overflow
🌐
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.

Discussions

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
Some way to get arguments of current function for passing along to another function even when not using *args/**kw
Often times I have a function that does not make use of *args/**kw for various reasons but still needs to pass along all arguments to another function. An example would be: def other_fun(a, b, c=7, d=9): ... def … More on discuss.python.org
🌐 discuss.python.org
0
1
June 10, 2024
Passing a function with arguments as an argument of another function
You don't need to pass the function as a parameter of the second function. It should work without. If you absolutely HAVE to, I'm pretty sure you can pass X as a third argument and use that when you call the first function. More on reddit.com
🌐 r/learnpython
3
1
September 4, 2020
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
1
October 31, 2022
🌐
GeeksforGeeks
geeksforgeeks.org › python › passing-function-as-an-argument-in-python
Passing function as an argument in Python - GeeksforGeeks
July 12, 2025 - Explanation: lambda x: x ** 2 is passed to fun(), which squares the input 5 to produce 25. A wrapper function (decorator) enhances another function's behavior without modifying it. It takes a function as an argument and calls it within the wrapper.
Top answer
1 of 9
346

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)
🌐
Python Morsels
pythonmorsels.com › passing-functions-arguments-other-functions
Passing functions as arguments to other functions - Python Morsels
June 3, 2021 - This get_two function accepts a function as an argument: >>> def get_two(func, thing): ... return func(thing), func(thing) ... The one thing that you can do with every function is call it. 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.
🌐
AskPython
askpython.com › home › python: how to pass a function as an argument?
Python: How to pass a function as an argument? - AskPython
July 11, 2021 - Like user-defined and lambda functions we can also pass an operator function as an argument to another function. Here we will be using operator.mul() function from the operator module and pass it to the reduce() function which is defined in the functools module along with a Python list.
🌐
Trey Hunner
treyhunner.com › 2020 › 01 › passing-functions-as-arguments
Passing a function as an argument to another function in Python
January 14, 2020 - We normally type my_string.casefold() but str.casefold(my_string) is what Python translates that to. That’s a story for another time. Here we’re finding the string with the most letters in it: If there are multiple maximums or minimums, the earliest one wins (that’s how min/max work): Here’s a function which will return a 2-item tuple containing the length of a given string and the case-normalized version of that string: We could pass this length_and_alphabetical function as the key argument to sorted to sort our strings by their length first and then by their case-normalized representation:
Find elsewhere
🌐
W3Schools
w3schools.com › python › gloss_python_function_arguments.asp
Python Function Arguments
When the function is called, we ... The terms parameter and argument can be used for the same thing: information that are passed into a function....
🌐
Python Course
python-course.eu › python-tutorial › passing-arguments.php
25. Passing Arguments | Python Tutorial | python-course.eu
November 8, 2023 - If you pass immutable arguments like integers, strings or tuples to a function, the passing acts like call-by-value. The object reference is passed to the function parameters. They can't be changed within the function, because they can't be changed at all, i.e.
🌐
Educative
educative.io › answers › how-to-pass-a-parameter-to-a-function-in-python
How to pass a parameter to a function in Python
For example greet_customer(name) ... (name) as its parameter. The purpose of function parameters in Python is to allow a programmer using the function to define variables dynamically within the function. It’s important to note that after passing a parameter to a function, an argument should be ...
🌐
Python.org
discuss.python.org › python help
Some way to get arguments of current function for passing along to another function even when not using *args/**kw - Python Help - Discussions on Python.org
June 10, 2024 - Often times I have a function that does not make use of *args/**kw for various reasons but still needs to pass along all arguments to another function. An example would be: def other_fun(a, b, c=7, d=9): ... def myfun(a, b, c=7, d=9): v = other_fun(a, b, c=c, d=d) # do some other post processing of v, often times depending on the input arguments ...
🌐
TutorialsPoint
tutorialspoint.com › How-to-pass-Python-function-as-a-function-argument
How to pass Python function as a function argument?
April 11, 2025 - The statement return [expression] ... passing back an expression to the caller. A return statement with no arguments is the same as return None. def function_name( parameters ): "function_docstring" function_suite return [expression] By default, parameters have a positional behavior and you need to inform them in the same order that they were defined. Once the function is defined, you can execute it by calling it from another function or directly from the Python ...
🌐
py4u
py4u.org › blog › python-passing-a-function-with-parameters-as-parameter
How to Pass a Python Function with Parameters as Another Function's Parameter: A Step-by-Step Guide
Use lambdas for simple, one-off parameter binding. Use functools.partial for fixing some arguments and leaving others flexible. Use custom helper functions for readability and complex logic. Avoid invoking the function accidentally—pass the callable, not its result. With these tools, you’ll be able to handle event handlers, decorators, parallel processing, and more with confidence. Python Official Documentation: First-Class Functions
🌐
Medium
medium.com › @lynzt › python-pass-a-function-to-another-function-and-run-it-with-args-b24141312bd7
Python — pass a function to another function and run it (with args) | by lindsay | Medium
December 19, 2016 - The “issue” was that there was a function that was script specific, but the rest of the functionality could go into a helper file. Lucky for me, python allows functions to be passed to another function which can then run it. I also used the ability to pass function args as a dictionary.
🌐
Medium
medium.com › @gauravverma.career › parameters-arguments-in-python-function-74a057662c0e
Parameters/Arguments in python function | by Gaurav Verma | Medium
December 7, 2025 - For more details, please refer ... we can pass the default value to parameter(s) of function in form of <parameter_name> = <default_value>...
🌐
Qissba
qissba.com › home › blog › parameter passing methods in python | 3 important method or techniques | cbse class 12
Parameter Passing methods in Python | 3 Important Method or Techniques | CBSE Class 12 Qissba -
May 10, 2025 - Answer: To pass a parameter to a function in Python, you can simply include the parameter inside the parentheses of the function call. ... In this example, the greet function takes a parameter called name, which is used to print a greeting message.
🌐
GeeksforGeeks
geeksforgeeks.org › python › deep-dive-into-parameters-and-arguments-in-python
Python Function Parameters and Arguments - GeeksforGeeks
To read in detail, refer - *args and **kwargs in Python · Keyword Arguments is an argument passed to a function or method which is preceded by a keyword and equal to sign (=). The order of keyword argument with respect to another keyword argument does not matter because the values are being explicitly assigned...
Published   July 23, 2025
🌐
Real Python
realpython.com › python-pass-by-reference
Pass by Reference in Python: Background and Best Practices – Real Python
October 21, 2023 - Using id(), you can verify the ... address as their original variables. Reassigning the argument within the function gives it a new address while the original variable remains unmodified....
🌐
Reddit
reddit.com › r/learnpython › passing a function with arguments as an argument of another function
r/learnpython on Reddit: Passing a function with arguments as an argument of another function
September 4, 2020 -

I'm unsure about executing the following code to compute a numeric derivative. I've been able to pass func(*args, **kwargs) for a decorator before. However, I am having trouble carrying it out in this particular case:

def func(x):
    return x*(x-1)

def derivative(func, delta):
    
    return (func(x+delta)-func(x))/delta

derivative(func(1), 10^-2)

Right now I'm not passing anything correctly, but my other attempts haven't been successful so I'm just leaving the code in the way I wanted to execute it initially. How would I go about passing the x argument into the derivative?

🌐
Studytonight
studytonight.com › python-howtos › how-to-pass-a-method-as-an-argument-in-python
How to Pass a Method as an Argument in Python? - Studytonight
February 23, 2021 - Lambda functions are just like regular Python functions, with a few caveats. Python implements the map() function where the first parameter is a function and the second is iterable. In this example, the function call passes the function sqr(x) as a function argument using the map method.