Open links in new tab
    • Work Report
    • Email
    • Rewrite
    • Speech
    • Title Generator
    • Smart Reply
    • Poem
    • Essay
    • Joke
    • Instagram Post
    • X Post
    • Facebook Post
    • Story
    • Cover Letter
    • Resume
    • Job Description
    • Recommendation Letter
    • Resignation Letter
    • Invitation Letter
    • Greeting Message
    • Try more templates
  1. In Python, arguments are passed by object reference (also called call by sharing). This means the function receives a reference to the same object, but reassigning the parameter inside the function won’t affect the caller’s variable — only mutating a mutable object will.

    Example: Mutable vs Immutable

    def modify_list(lst):
    lst.append(4) # in-place modification

    def reassign_list(lst):
    lst = [99] # rebinds local name, no effect outside

    nums = [1, 2, 3]
    modify_list(nums)
    print(nums) # [1, 2, 3, 4] - changed outside too

    reassign_list(nums)
    print(nums) # [1, 2, 3, 4] - unchanged
    Copied!

    Here, modify_list mutates the original list (mutable), so changes persist. reassign_list points lst to a new list locally — the caller’s reference is unaffected.

    Working with Immutable Types

    Immutable objects (like int, str, tuple) can’t be changed in place. To “simulate” pass-by-reference for them:

    • Return and reassign:

    def increment(x):
    return x + 1

    n = 5
    n = increment(n)
    print(n) # 6
    Copied!
    • Wrap in a mutable container:

    Feedback
  2. python - How do I pass a variable by reference? - Stack …

    Jun 12, 2009 · Python: Python is “pass-by-object-reference”, of which it is often …

    • Reviews: 16

      Code sample

      def use_a_wrapper_to_simulate_pass_by_reference(stuff_to_change):
        new_string = something_to_do_with_the_old_string(stuff_to_change[0])
        stuff_to_change[0] = new_string
      wrapper = [my_string]
      use_a_wrapper_to_simulate_pass_by_reference(wrapper)...
    • Is Python call by reference or call by value

      Jul 12, 2025 · What is Call By Reference in Python? In Python, "call by reference" is a way of handing arguments to functions where the reference to the real object …

    • Pass by Reference in Python: Background and Best …

      Aug 10, 2020 · Learn how Python handles function arguments differently from other languages and how to use mutable types to achieve pass by reference. Explore …

    • Call by Value vs Call by Reference in Python

      Sep 6, 2025 · Learn call by value vs call by reference in Python with simple examples. Understand mutable vs immutable objects and how Python handles …

    • How Passing by Object Reference Works in Python

      6 days ago · Python doesn't use call by value or call by reference. It passes by object reference, where the function receives a reference to the object, and whether that object can be modified in place …

    • Call by Value and Call by Reference in Python with Examples - Intellipaat

      Jul 3, 2025 · Call by Value and Call by Reference in Python are ways to pass arguments. Learn their differences, how they work, and understand each with examples.

    • People also ask
      Loading
      Unable to load answer
    • How to Call by Reference in Python - TechBloat

      In Python, calling by reference means passing a variable to a function such that modifications within the function affect the original object. Understanding when and how to do this is crucial for efficient …

    • Python’s Call by Object Reference: Unraveling the Mystery

      Jan 31, 2024 · In this blog, we’ll delve into the intricacies of Python’s argument passing mechanism, demystifying the common misconception that Python is …

    • Python's Pass-by-Reference: Concepts, Usage, and Best Practices

      Mar 24, 2025 · This blog post will delve deep into the concept of what is commonly referred to as pass - by - reference in Python, how to use it effectively, common scenarios where it is applied, and best …

    • What is Call by Value and Call by Reference in Python?

      Jul 7, 2024 · In this article by Scaler Topics, we will learn what Call by value and Call by reference exactly mean in Python programming language.