October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Call by Value vs Call by Reference in Python: What Actually Happens

Python binds parameters to objects; rebinding a parameter does not change the caller’s variable, while mutating a shared mutable object can be visible outside the function.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Python does not pass arguments by traditional call by reference. Its official FAQ says arguments are “passed by assignment”: a parameter becomes a local name for the object supplied by the caller. Reassigning that local name does not change the caller’s variable, but mutating a shared mutable object can be visible outside the function.

What Python does when you call a function

When a function is called, Python binds each parameter name to the object supplied for that argument. The parameter and the caller’s variable are separate names, even though both may refer to the same object. The Python Programming FAQ describes this as arguments being “passed by assignment.” See the Python 3.14.8 Programming FAQ.

This distinction separates a variable binding from an object’s state. Assigning a different object to the local parameter changes only that local name. Calling a method that mutates a shared object changes the object itself, so the caller can observe the change. The Python 3.13.16 data model reference describes objects and their mutability; mutability is a property of objects, not an argument-passing mode.

Rebinding a parameter versus mutating an object

These two functions receive the same list, but perform different operations:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
def rebind(value):
    value = ["new"]

def mutate(value):
    value.append("new")

items = ["old"]
rebind(items)
print(items)  # ['old']
mutate(items)
print(items)  # ['old', 'new']

Rebinding changes only the local name

At the start of rebind(items), both items and the local parameter value refer to the original list. The assignment value = ["new"] makes value refer to a newly created list. It does not redirect items, which still refers to the original list.

Mutation changes the shared list

At the start of mutate(items), value and items refer to the same list. The append method changes that list in place. Since the caller’s name still refers to that object, printing items shows the added element.

Why “mutable means by reference” is misleading

Python does not switch between call by value and call by reference depending on whether an argument is mutable. The same name-binding rule applies to every argument. Mutability explains what an operation can do to the object after the parameter has been bound; it does not determine how the argument is passed.

For example, a tuple is immutable as a container, but it can contain a mutable object such as a list. A function cannot replace an element of the tuple, but it may mutate the contained list, and that change can be observed through the tuple. This is another reason to distinguish the object’s state from the name that refers to it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some teaching materials describe Python as passing references to objects by value. SciPy lecture notes use the formulation “parameters to functions are references to objects, which are passed by value.” The wording differs, but the practical point is that a parameter is a separate name bound to an object; it is not an alias for the caller’s variable. See the SciPy lecture notes.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How to return replacement values

If a function calculates new values that the caller should use, return them and assign the result where the function is called. The Python FAQ says returning a tuple is almost always the clearest way to return multiple results:

def updated(a, b):
    return "new-value", b + 1

x, y = updated(x, y)

The caller’s names are updated by the assignment on the final line, not by the function rebinding its local parameters. Mutating a passed list or dictionary can also communicate a result, but it changes shared state and can make code harder to follow when a return value would suffice.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.