See "partial" from the functools module A partial function is pretty much a function with some of its arguments filled in Answer from E02Y on reddit.com
🌐
Python Course
python-course.eu › python-tutorial › passing-arguments.php
25. Passing Arguments | Python Tutorial | python-course.eu
November 8, 2023 - In call-by-value, the argument expression is evaluated, and the result of this evaluation is bound to the corresponding variable in the function. So, if the expression is a variable, its value will be assigned (copied) to the corresponding parameter. This ensures that the variable in the caller's scope will stay unchanged when the function returns. Call by Reference In call-by-reference evaluation, which is also known as pass-by-reference, a function gets an implicit reference to the argument, rather than a copy of its value.
🌐
W3Schools
w3schools.com › python › gloss_python_function_arguments.asp
Python Function Arguments
Information can be passed into functions as arguments. Arguments are specified after the function name, inside the parentheses. You can add as many arguments as you want, just separate them with a comma.
Discussions

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
Passing functions with arguments to another function in Python? - Stack Overflow
How can I bind arguments to a function in Python? (7 answers) Closed 3 years ago. Is it possible to pass functions with arguments to another function in Python? 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
Best way to pass arguments to a function that requires a large number of inputs?
For me it sounds like an insane amount of arguments for just one function and is in need of refractoring. More on reddit.com
🌐 r/learnpython
38
24
November 4, 2023
🌐
GeeksforGeeks
geeksforgeeks.org › python › passing-function-as-an-argument-in-python
Passing function as an argument in Python - GeeksforGeeks
July 12, 2025 - Explanation: apply_lambda() function applies the lambda function lambda x: x ** 2 to 2, returning 4. Python provides built-in functions that take other functions as arguments .
🌐
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.

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)
🌐
Educative
educative.io › answers › how-to-pass-a-parameter-to-a-function-in-python
How to pass a parameter to a function in Python
# defining a funtion and passing the name parameter to it ... In the code above, we use the def keyword to show that we are defining a function. The name of our function is greet_customer(name). (name) is the parameter of the function. The double line breaks must be included after defining a function. (Theophilus) and (Chidalu) are the arguments passed to the greet_customer(name) function whenever it is called.
Find elsewhere
🌐
Reddit
reddit.com › r/learnpython › best way to pass arguments to a function that requires a large number of inputs?
r/learnpython on Reddit: Best way to pass arguments to a function that requires a large number of inputs?
November 4, 2023 -

For example, suppose I had a function which required 50 arguments and these arguments were stored in an object with 500 properties.

I could simply pass the object to the function, but then I’d be passing an addition 450 values that are not needed by the function. This feels like bad practice, but I’m not aware of whether or not that’s true.

EDIT: 50 args does indeed sound excessive (and I’ll admit that it’s a slight exaggeration). However, quite a lot of arguments are taken by this function because it is responsible for aggregating results from other models. In addition to taking in lots of inputs, there are also various aggregation settings that the user may specify.

🌐
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 = ...
🌐
Python.org
discuss.python.org › python help
Passing argument to function from command line - Python Help - Discussions on Python.org
June 25, 2025 - My son wrote a command line program in ruby for me. I want to convert it to python. To run the program he has done this on the command line; “./myProgram.rb ‘argument’”. Then the 'argument ’ is passed into the progra…
🌐
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 ...
🌐
Programiz
programiz.com › python-programming › function-argument
Python Function Arguments (With Examples)
Arbitrary arguments allow us to pass a varying number of values during a function call. We use an asterisk (*) before the parameter name to denote this kind of argument. For example, # program to find sum of multiple numbers def find_sum(*numbers): result = 0 for num in numbers: result = result ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › deep-dive-into-parameters-and-arguments-in-python
Python Function Parameters and Arguments - GeeksforGeeks
Arguments are the actual values that you pass to the function when you call it. These values replace the parameters defined in the function.
Published   July 23, 2025
🌐
TutorialsPoint
tutorialspoint.com › How-to-pass-Python-function-as-a-function-argument
How to pass Python function as a function argument?
April 11, 2025 - As variable in Python is a label or reference to the object in the memory, both the variables used as actual argument as well as formal arguments really refer to the same object in the memory. We can verify this fact by checking the id() of the passed variable before and after passing. In the following example, we are checking the id() of a variable. def testfunction(arg): print ("ID inside the function:", id(arg)) var = "Hello" print ("ID before passing:", id(var)) testfunction(var)
🌐
Trey Hunner
treyhunner.com › 2020 › 01 › passing-functions-as-arguments
Passing a function as an argument to another function in Python
January 14, 2020 - This function expects the predicate argument to be a function (technically it could be any callable). When we call that function (with predicate(item)), we pass a single argument to it and then check the truthiness of its return value. A lambda expression is a special syntax in Python for creating an anonymous function.
🌐
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.
🌐
IncludeHelp
includehelp.com › python › function-as-argument-example.aspx
Python Passing a function as an argument
April 25, 2025 - Consider the below syntax (or, approach) to pass a function as an argument: def func1(): body def func2(): body # Calling func2(func1) Here, we are defining two function foo() and koo(), function koo() will take an argument x that will be a function while calling.
🌐
Towards Data Science
towardsdatascience.com › home › latest › python args, kwargs, and all other ways to pass arguments to your function
Python args, kwargs, and All Other Ways to Pass Arguments to Your Function | Towards Data Science
January 19, 2025 - With kwargs we can add some extra arguments to the introduce function. No Need to Ever Write SQL Again: SQLAlchemy’s ORM for Absolute Beginners · When you really don’t want to mix up your parameters you can force your function to only accept keyword arguments. A perfect use-case for this could be a function that transfers money from one account to another. You really don’t want to pass the account numbers positionally because then you run the risk that a developer switch up the account numbers accidentally: