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.

Answer from David Z on Stack Overflow
๐ŸŒ
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.
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)
Discussions

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
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
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 argument to function from command line
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 program to be processed. I want to do the same in python. More on discuss.python.org
๐ŸŒ discuss.python.org
0
0
June 25, 2025
๐ŸŒ
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.
๐ŸŒ
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 .
๐ŸŒ
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.
๐ŸŒ
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.

Find elsewhere
๐ŸŒ
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.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 ...
๐ŸŒ
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 = ...
๐ŸŒ
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
Top answer
1 of 8
10

In a few words, they're data that gets "passed into" the function to tell it what to do. Wikipedia has details.

http://en.wikipedia.org/wiki/Function_argument

For instance, your hi() function might need to know who to say hello to:

def hi(person):
    print "Hi there " + person + ", how are you?"

Or a mathematical function might need a value to operate on:

def square(x):
     return x * x
2 of 8
7

This is not a Python question, but rather a generic programming question. A very basic one.


Before answering the question about arguments, and in view of the other questions you asked, it is useful to discuss the concept of variables.
A variable is a named piece of memory where information of interest to the underlying program can be stored and retrieved. In other words, it is a symbolic name, chosen by the programmer, that is associated to its contents. Using various language constructs generally known as assignments, the programmer can read or write the contents of a variable.
It is important to note that the value (i.e. the content) of a variable needn't be defined when the program is written. It is only necessary at run-time. This allows the program to describe actions to be performed on symbolic elements without knowing exactly the value these elements have. Consider this snippet, part of a bigger program:

# ... some logic above
ball_volume = 4.0 / 3 * math.pi * ball_radius
if ball_volume > 200:
   print ("Man, that's a big ball")
# ... more logic below

At the time the program is written one doesn't need to know the actual value of ball_radius; yet, with the assumption that this variable will contain the numeric value of some hypothetical ball, the snippet is capable of describing how to compute the ball's volume. In this fashion, when the program is running, and somehow (more on this later) the ball_radius variable has been initialized with some appropriate value, the variable ball_volume can too be initialized and used, here in the conditional statement (if), and possibly below. (At some point the variable may go out-of-scope, but this concept which controls when particular variables are accessible to the program is well beyond this primer).
In some languages the type of data that may be associated with a particular variable needs to be explicitly defined and cannot change. For example some variables could hold only integer values, other variables string values (text) etc. In Python there is no such restriction, a variable can be assigned and re-assigned to any type of data, but of course, the programmer needs to keep track of this for example to avoid passing some text data to a mathematical function.

The data stored inside variable may come from very different sources. Many of the examples provided in tutorials and introductory documentation have this data coming from keyboard input (as when using raw_input as mentioned in some of your questions). That is because it allows interactive tests by the people trying out these tutorial snippets. But the usefulness of programs would be rather limited if variables only get their data from interactive user input. There are many other sources and this is what makes programming so powerful: variables can be initialized with data from:

  • databases
  • text files or files various text-base formats (XML, JSON, CSV..)
  • binary files with various formats
  • internet connections
  • physical devices: cameras, temperature sensors...

In a nutshell, Arguments, also called Parameters, are variables passed to the function which [typically] are used to provide different output and behavior from the function. For example:

>>> def say_hello(my_name):
...    print("Hello,", my_name, "!")

>>> say_hello("Sam")
Hello, Sam !
>>> customer_name = "Mr Peter Clark"    #imagine this info came from a database
>>> # ...
>>> say_hello(customer_name)
Hello, Mr Peter Clark !
>>>

In the example above, my_name is just like any local variable of the say_hello function; this allows the function to define what it will do with the underlying value when the function is called, at run-time.
At run-time, the function can be called with an immediate value (a value that is "hard-coded" in the logic, such as "Sam" in the example), or with [the value of] another variable (such as customer_name). In both cases the value of the function's my_name variable gets assigned some value, "Sam" and "Mr Peter Clark" respectively. In the latter case, this value is whatever the customer_name variable contains. Note that the names of the variables used inside the function (my_name) and when the function is called (customer_name) do not need to be the same. (these are called the "formal parameter(s)" and the "actual parameters" respectively)

Note that while typically most arguments as passed as input to a function, in some conditions, they can be used as output, i.e. to provide new/modified values at the level of the logic which called the function. Doing so requires using, implicitly or explicitly, the proper calling convention specification (See Argument passing conventions below)


Now... beyond this very basic understanding of the purpose of parameters, things get a little more complicated than that (but not much). I'll discuss these additional concepts in general and illustrate them as they apply to Python.

Default values for arguments (aka "optional" arguments)
When the function is declared it may specify the default value for some parameters. These values are used for the parameters which are not specified when the function is called. For obvious reasons these optional parameters are found at the end of the parameter list (otherwise the language compiler/interpreter may have difficulty figuring out which parameter is which...)

>>> def say_hello(dude = "Sir"):
...     print("Hello,", dude, "!")
...
>>> say_hello()
Hello, Sir !
>>> say_hello("William Gates")
Hello, Bill !            #just kidding ;-)
Hello, William Gates !   # but indeed. works as the original function when param
                         # is specified

Variable number of parameters
In some cases it may be handy to define a function so that it may accept a variable number of parameters. While such lists of parameter values ultimately get passed in some kind of container (list, array, collection...) various languages offers convenient ways of accessing such parameter values.

>>> def add_many(operand1, *operands):
...    Sum = operand1
...    for op in operands:
...       Sum += op
...    return Sum
...
>>> add_many(1, 3, 5, 7, 20)
36
>>> add_many(1, 3)
4

Named Arguments (Keyword Arguments)
With Python and a few other languages, it is possible to explicitly name the arguments when calling the function. Whereby argument passing is by default based a positional basis ("1st argument, 2nd argument etc.), Python will let you name the arguments and pass them in any order. This is mostly a syntactic nicety, but can be useful, in combination with default arguments for functions that accept very many arguments. It is also a nice self-documenting feature.

>>> def do_greetings(greeting, person):
...    print (greeting, "dear", person, "!")
...
>>> do_greetings(person="Jack", greeting="Good evening")
Good evening dear Jack !

In Python, you can even pass a dictionary in lieu of several named arguments for example, with do_greetingsas-is, imagine you have a dictionary like:

>>> my_param_dict = {"greeting":"Aloha", "person":"Alan"}

>>> do_greetings(**my_param_dict)
Aloha dear Alan !

In closing, and while the fancy ways of passing arguments, and the capability for methods to handle variable number of arguments are useful features of various languages, two key concepts need to be mentioned:

Argument passing convention : by value or by reference
So far all the functions we used didn't alter the value of the parameters passed to them. We can imagine however many instances when functions may want to do this, either to perform some conversion or computation on the said values, for its own internal use, or to effectively change the value of the variable so that the changes are reflected at the level of logic which called the function. That's where argument passing conventions come handy...
arguments which are passed by value may be altered by the function for its own internal computations but are not changed at the level of the calling method.
arguments which are passed by reference will reflect changes made to them, at the level of the calling method.
Each language specifies the ways that arguments are passed. A typical convention is to pass integers, numberic values and other basic types by value and to pass objects by reference. Most language also offer keyword that allow altering their default convention.

In python all arguments are passed by reference. However a few variables types are immutable (numbers, strings, tuples...) and they can therefore not be altered by the function.

Implicit "self" or "this" argument of class methods
In object oriented languages, methods (i.e. functions within a class) receive an extra argument that is the value of underlying object (the instance of the class), allowing the method to use various properties members of the class in its computation and/or to alter the value of some of these properties.

in Python, this argument is declared at the level of the method definition, but is passed implicitly. Being declared, it may be named most anything one wishes, although by convention this is typically called self.

>>> class Accumulator:
...   def __init__(self, initialValue = 0):
...        self.CurValue = initialValue
...   def Add(self, x):
...        self.CurValue += x
...        return self.CurValue
...
>>> my_accu = Accumulator(10)
>>> my_accu.Add(5)
15
>>> my_accu.Add(3)
18
๐ŸŒ
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.
๐ŸŒ
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)
๐ŸŒ
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.
๐ŸŒ
Real Python
realpython.com โ€บ python-pass-by-reference
Pass by Reference in Python: Background and Best Practices โ€“ Real Python
October 21, 2023 - As you can see, the refParameter of squareRef() must be declared with the ref keyword, and you must also use the keyword when calling the function. Then the argument will be passed in by reference and can be modified in place. Python has no ref keyword or anything equivalent to it.