🌐
GeeksforGeeks
geeksforgeeks.org › python › is-python-call-by-reference-or-call-by-value
Is Python call by reference or call by value - GeeksforGeeks
July 12, 2025 - In Python, the common way of passing ... means that when you pass a variable to a function, you're essentially handing over the actual value of the variable itself, not the reference to the object it's pointing to....
🌐
Quora
quora.com › What-is-call-by-value-in-Python
What is “call by value” in Python? - Quora
Answer: There is no such thing as ‘call by value’ in Python. All arguments in Python are passed by ‘Call by Assignment’, or ‘Call by Object Reference’; what is passed around is an object reference. When you pass an immutable object as an argument - for instance a number, a string, ...
Discussions

call by value or call by reference
There's no distinction between call by value vs call by reference in python. Every name is a reference. Variables, function arguments and return values are all references. More on reddit.com
🌐 r/learnpython
18
4
November 11, 2022
variables - Python functions call by reference - Stack Overflow
When you pass a parameter to a ... the value of the parameter on leaving the function.The only way to do this is by using the global reserved word (or as i understand it currently). ... k = 2 def foo (n): n = n * n #clarity regarding comment below square = n return square j = foo(k) print j print k ... In this example the variable n is changed. Is there any way in Python to call a function ... More on stackoverflow.com
🌐 stackoverflow.com
Python ist weder Call by Value noch Call by Reference
6.8M subscribers in the programming community. Computer Programming More on reddit.com
🌐 r/programming
Is Python call-by-value or call-by-reference? Neither.
The way Python treats variables is the interesting part (which the author pointed out, but I don't think it can be stressed enough). Assignment does not modify a variable; rather, it rebinds a variable. Consider this snippet: def do_something(x, y): x = 3 y[0] = 4 a = 1 b = [2] do_something(a, b) Translating this to a C-like language, it would look like this: PyObj *do_something(PyObj *x, PyObj *y) { x = &3; (*y)[0] = &4; return &None; } PyObj *a; PyObj *b; a = &1; b = &[2]; do_something(a, b); The argument passing is similar to how other languages work, but the assignment differs: b = &[2]; In some other languages, it might look more like: *b = [2]; More on reddit.com
🌐 r/Python
14
20
March 26, 2015
🌐
Python Guides
pythonguides.com › python-pass-by-reference-or-value
Call by Value vs Call by Reference in Python
September 6, 2025 - Python uses call by object reference. Immutable objects (int, str, tuple) behave like call by value.
🌐
Reddit
reddit.com › r/learnpython › call by value or call by reference
r/learnpython on Reddit: call by value or call by reference
November 11, 2022 -

I'm having a difficult time understanding this concept. Suppose for example, that a function accepts a list as an argument. Does the function receive a copy of the list or does it receive a reference to the list?

Top answer
1 of 5
6
There's no distinction between call by value vs call by reference in python. Every name is a reference. Variables, function arguments and return values are all references.
2 of 5
3
I'm sick and tired of that question. So I wrote that up hoping it will forever disappear (Wishful thinking... I known...) The concept of passing by value or reference do not exist in python. The important concept in python are mutability and immutability. Variable names are not pointer to a place in memory, they are labels attached to a value that exist somewhere in memory. Multiple labels can be attached to the same value if the type of that value is immutable (int, float, string, tuple, etc). immutable example: x = 2048 # the value 2048 is created and the label 'x' is attached to it y = 2048 # the label 'y' is attached to the already existing value 2048 print(x is y) # are the label 'x' and 'y' attached to a value that reside at the same memory address? # ====> True # yes they do x = x+1 # create a new value that is 2048+1 (2049) print(x is y) # Do 2048 and 2049 reside at the same place in memory =====> False # No they don't Every time a new value is created, somewhere in memory, the label, variable name on the left side of the assignment is re-attached to that new value. Which is usually very confusing for C programmer who expect their variable to be pointers to a specific place in memory and stay that way! Immutable exemple 2: i = 0 while i < 5: print(id(i)) # show me where the value attached to i reside in memory i = i + 1 # create a new value, attached the label i to that new value # =======> 2588411691216 Every time a new value is created # =======> 2588411691248 it is created at a new place in memory # =======> 2588411691280 and the label 'i' is re-attached to that new value. # =======> 2588411691312 The memory allocated for the old values # =======> 2588411691344 will be freed by the Garbage Collector (GC) Mutable types. When you get to mutable types things are a bit different. Since they are mutable and the value can change 'in-place' a new value is created for each literal value expressed in the code: x = [1,2,3] # create a list containing the value 1,2,3 and attach the label 'x' to it y = [1,2,3] # create another list containing the value 1,2,3 and attach the label 'y' to it print(x is y) # are both labels attached to the same value? x[0] = 'a' print(x) print(y) # ======> False # No they're not # ======> ['a', 2, 3] # x has been changed # ======> [1, 2, 3] # y has not been changed # BUT x = [1,2,3] # create a list containing the value 1,2,3 and attach the label 'x' to it y = x # attached the label 'y' to the same value that 'x' is attached to print(x is y) # are both labels attached to the same value? x[0] = 'a' print(x) print(y) # ======> True # yes they are! # ======> ['a', 2, 3] # x has been changed # ======> ['a', 2, 3] # y has also been changed Arguments & Parameters When you pass parameters to a function, the arguments that it receives are transferred the same way as if you had done a argument = parameters So arguments labels attached to immutable type will be attacged to the same value, but will be re-attached to a new value if assigned to that new value. And arguments labels attached to mutable type will be attached to the same value and will stay attached to that value if it changes. Example & Proof x = 2600 lst = [1, 2, 3] def check(an_x, an_lst): global x global lst print(f"{(x is an_x)=} Labels 'x' and 'an_x' are attached to the same value in memory") print(f"{(lst is an_lst)=} Labels 'lst' abd 'an_lst' are also attached to the same value in memory ") an_x += 1 print(f"{x=}") print(f"{an_x=}") print(f"{(x is an_x)=} A new value was created and the label 'an_x' is now attached to that new value") an_lst[0] = 'a' print(f"{lst=}") print(f"{an_lst=}") print( f"{(lst is an_lst)=} The list an_lst was changed and the label 'lst' and 'an_lst' still point to the same value") check(x, lst) # OUPUT (x is an_x)=True Labels 'x' and 'an_x' are attached to the same value in memory (lst is an_lst)=True Labels 'lst' abd 'an_lst' are also attached to the same value in memory x=2600 an_x=2601 (x is an_x)=False A new value was created and the label 'an_x' is now attached to that new value lst=['a', 2, 3] an_lst=['a', 2, 3] (lst is an_lst)=True The list an_lst was changed and the label 'lst' and 'an_lst' still point to the same value Q.E.D. Edit: a few words
🌐
Rebus Community
press.rebus.community › programmingfundamentals › chapter › call-by-value-vs-call-by-reference
Call by Value vs. Call by Reference – Programming Fundamentals
December 15, 2018 - In call by value, a parameter acts within the function as a new local variable initialized to the value of the argument (a local (isolated) copy of the argument).
🌐
Medium
medium.com › @lokeshsharma596 › is-python-call-by-value-or-call-by-reference-2dd7db74dbd0
Is Python Call by Value or Call by Reference? | by Lokesh sharma | Medium
November 10, 2019 - In pass-by-value, the function receives a copy of the argument objects passed to it by the caller, stored in a new location in memory.
🌐
Scaler
scaler.com › home › topics › what is call by value and call by reference in python?
What is Call by Value and Call by Reference in Python? - Scaler Topics
July 7, 2024 - Still, if a variable refers to a mutable type, any change in the value of the mutable type will not change the memory address of the variable. Arguments are passed by assignment in Python. The assignment creates references to objects. Hence, Immutable objects passed as arguments are referred as in Call by Value and Mutable objects, when passed as arguments are referred to as Call by Reference.
🌐
Medium
medium.com › techtofreedom › python-is-neither-call-by-value-nor-call-by-reference-2a0c8f6f4a8f
Python Is Neither Call by Value Nor Call by Reference | by Yang Zhou | TechToFreedom | Medium
February 1, 2024 - In Python, the concept of “call by value” or “call by reference” doesn’t exactly apply as it does in languages like C or C++.
Find elsewhere
🌐
DEV Community
dev.to › adarshrawat7400 › how-call-by-value-and-call-by-reference-work-in-python-am2
How Call by Value and Call by Reference Work in Python? - DEV Community
November 15, 2021 - Immutable Objects Datatypes that ... **(int, float, bool, string, unicode, tuple). So when Mutable objects are passed to the function call then it is treated as **call by value.**...
🌐
IncludeHelp
includehelp.com › python › types-of-function-calling-with-examples.aspx
Python Function Call by Value and Call by Reference
In Python, call by value means passing immutable objects where changes don’t affect the original, whereas call by reference means passing mutable objects where changes can modify the original data.
🌐
Medium
medium.com › @sanwarkumarlal1111 › call-by-value-and-call-by-refrences-python-handles-in-different-ways-48a2a2b8a98b
Call by Value and Call by Reference — Python handles in a different way | by sanwar | Medium
March 25, 2024 - Conclusion Immutable objects (integers, strings, tuples) behave like call by value. Modifications within the function don’t affect the original object outside the function. Mutable objects (lists, dictionaries, sets) behave more like call by reference.
🌐
TutorialsPoint
tutorialspoint.com › pass-by-reference-vs-value-in-python
Pass by reference vs value in Python
November 20, 2024 - In Python Call by Value and Call by Reference are two types of generic methods to pass parameters to a function. In the Call-by-value method, the original value cannot be changed, whereas in Call-by-reference, the original value can be changed.
🌐
DataFlair
data-flair.training › blogs › python-program-on-call-by-value-and-return-by-value
Python Program on call by value and return by value - DataFlair
February 28, 2024 - In Python, function call by value ... data. When a function is called by value, the actual values of the arguments are passed to the function, creating a copy of the data....
🌐
GeeksforGeeks
geeksforgeeks.org › python › is-python-call-by-reference-or-call-by-value
Is Python call by reference or call by value - GeeksforGeeks
July 12, 2025 - In Python, the common way of passing ... means that when you pass a variable to a function, you're essentially handing over the actual value of the variable itself, not the reference to the object it's pointing to....
🌐
GeeksforGeeks
geeksforgeeks.org › pass-by-reference-vs-value-in-python
Pass by reference vs value in Python - GeeksforGeeks
August 9, 2024 - We pass an integer in function call_by_value(). Integers are immutable objects hence Python works according to call by value, and the changes made in the function are not reflected outside the function.
Top answer
1 of 12
224

There are essentially three kinds of 'function calls':

  • Pass by value
  • Pass by reference
  • Pass by object reference

Python is a pass by object reference programming language.

Firstly, it is important to understand that a variable, and the value of the variable (the object) are two separate things. The variable 'points to' the object. The variable is not the object. Again:

THE VARIABLE IS NOT THE OBJECT

Example: in the following line of code:

>>> x = []

[] is the empty list, x is a variable that points to the empty list, but x itself is not the empty list.

Consider the variable (x, in the above case) as a box, and 'the value' of the variable ([]) as the object inside the box.

Pass by object reference (Case in python)

Here, "Object references are passed by value."

def append_one(li):
    li.append(1)
x = [0]
append_one(x)
print x

Here, the statement x = [0] makes a variable x (box) that points towards the object [0].

On the function being called, a new box li is created. The contents of li are the SAME as the contents of the box x. Both the boxes contain the same object. That is, both the variables point to the same object in memory. Hence, any change to the object pointed at by li will also be reflected by the object pointed at by x.

In conclusion, the output of the above program will be:

[0, 1]

Note:

If the variable li is reassigned in the function, then li will point to a separate object in memory. x however, will continue pointing to the same object in memory it was pointing to earlier.

Example:

def append_one(li):
    li = [0, 1]
x = [0]
append_one(x)
print x

The output of the program will be:

[0]

Pass by reference

The box from the calling function is passed on to the called function. Implicitly, the contents of the box (the value of the variable) are passed on to the called function. Hence, any change to the contents of the box in the called function will be reflected in the calling function.

Pass by value

A new box is created in the called function, and copies of contents of the box from the calling function are stored into the new boxes.

2 of 12
89

You can not change an immutable object, like str or tuple, inside a function in Python, but you can do things like:

def foo(y):
  y[0] = y[0]**2

x = [5]
foo(x)
print x[0]  # prints 25

That is a weird way to go about it, however, unless you need to always square certain elements in an array.

Note that in Python, you can also return more than one value, making some of the use cases for pass by reference less important:

def foo(x, y):
   return x**2, y**2

a = 2
b = 3
a, b = foo(a, b)  # a == 4; b == 9

When you return values like that, they are being returned as a Tuple which is in turn unpacked.

edit: Another way to think about this is that, while you can't explicitly pass variables by reference in Python, you can modify the properties of objects that were passed in. In my example (and others) you can modify members of the list that was passed in. You would not, however, be able to reassign the passed in variable entirely. For instance, see the following two pieces of code look like they might do something similar, but end up with different results:

def clear_a(x):
  x = []

def clear_b(x):
  while x: x.pop()

z = [1,2,3]
clear_a(z) # z will not be changed
clear_b(z) # z will be emptied
🌐
Python Course
python-course.eu › python-tutorial › passing-arguments.php
25. Passing Arguments | Python Tutorial | python-course.eu
November 8, 2023 - Call by Value The most common strategy ... is used in C and C++, for example. In call-by-value, the argument expression is evaluated, and the result of this evaluation is bound to the corresponding variable in the function....
🌐
Medium
medium.com › @gutta.sruthi1990 › call-by-value-and-call-by-reference-in-python-109a468add7f
Call by Value and Call by Reference in Python | by Gutta Sruthi | Medium
November 20, 2023 - New List 1 after append: [2, 4, ... of List1 is made · When Immutable objects such as whole numbers, strings, etc are passed as arguments to the function call, the it can be considered as Call by Value....
🌐
Mathspp
mathspp.com › blog › pydonts › pass-by-value-reference-and-assignment
Pass-by-value, reference, and assignment | Pydon't 🐍 | mathspp
November 3, 2021 - When you call a function in Python and give it some arguments... Are they passed by value? No! By reference? No! They're passed by assignment.