{"id":142596,"date":"2026-04-08T17:46:55","date_gmt":"2026-04-08T14:46:55","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=142596"},"modified":"2026-04-08T17:46:57","modified_gmt":"2026-04-08T14:46:57","slug":"understanding-pythons-pass-by-object-reference-mechanism","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/understanding-pythons-pass-by-object-reference-mechanism.html","title":{"rendered":"Understanding Python\u2019s Pass-by-Object-Reference Mechanism"},"content":{"rendered":"<p>Understanding how Python handles variables and function arguments is essential for writing predictable and bug-free code. Many developers coming from languages like C++ or Java often wonder whether Python uses call by value or call by reference. The answer is: neither exactly. Python uses a model often called pass by object reference or call by sharing. Let us delve into understanding how passing by object reference works in Python.<\/p>\n<h2><a name=\"section-1\"><\/a>1. Understanding Argument Passing: Value vs Reference<\/h2>\n<p>Before diving into Python\u2019s behavior, it is important to understand the two traditional models of passing arguments to functions: <a href=\"https:\/\/en.wikipedia.org\/wiki\/Evaluation_strategy#Call_by_value\" target=\"_blank\">call by value<\/a> and <a href=\"https:\/\/en.wikipedia.org\/wiki\/Evaluation_strategy#Call_by_reference\" target=\"_blank\">call by reference<\/a>. These concepts originate from languages like C, C++, and Java, and they help establish the foundation for understanding how Python behaves differently.<\/p>\n<h3>1.1 Call by Value: Working with Copies<\/h3>\n<p>In the call by value model, a function receives a <em>copy<\/em> of the variable\u2019s value rather than the original variable itself. This means that any changes made inside the function are applied only to the copied value and do not affect the original variable outside the function. This approach ensures data safety, as the original variable remains unchanged regardless of what happens inside the function.<\/p>\n<pre class=\"brush:python; wrap-lines:false;\">\ndef modify(x):\n    x = x + 10\n    print(\"Inside function:\", x)\n\na = 5\nmodify(a)\nprint(\"Outside function:\", a)  # Output: 5\n<\/pre>\n<p>The variable <code>a<\/code> is passed to the function <code>modify()<\/code>, where a separate copy of its value (<code>5<\/code>) is created and assigned to <code>x<\/code>. The operation <code>x = x + 10<\/code> modifies only this local copy, and as a result, the original variable <code>a<\/code> remains unchanged after the function call. This is why the output shows that the value of <code>a<\/code> is still <code>5<\/code> outside the function.<\/p>\n<h3>1.2 Call by Reference: Working with Original Data<\/h3>\n<p>In the call by reference model, instead of passing a copy, the function receives a reference (or address) to the original variable. This allows the function to directly modify the original data stored in memory. Any changes made inside the function are reflected outside the function because both the caller and the function refer to the same memory location.<\/p>\n<pre class=\"brush:python; wrap-lines:false;\">\n# Conceptual example of call by reference (Python does not use &amp;):\ndef modify(x):\n    x.append(10)  # works for mutable objects like lists\n<\/pre>\n<p>The parameter <code>x<\/code> acts as a reference to the original variable, meaning no separate copy is created and both names point to the same memory location. As a result, updating <code>x<\/code> directly modifies the original variable. This is why, in languages that support call by reference, the original value is modified after the function call.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<h3>1.3 How Python Actually Passes Arguments<\/h3>\n<p>Python does not strictly use call by value or call by reference. Instead, it employs a model often called <a href=\"https:\/\/en.wikipedia.org\/wiki\/Pass_by_sharing\" target=\"_blank\">pass by object reference<\/a> (or call by sharing). This means that when you pass a variable to a function, Python passes a reference to the object, not the actual value itself, but how the object behaves depends on its mutability.<\/p>\n<ul>\n<li>The function receives a reference to the object, meaning it points to the same memory location as the original variable.<\/li>\n<li>Whether changes inside the function affect the original variable depends on whether the object is mutable or immutable.<\/li>\n<\/ul>\n<h4>1.3.1 Understanding Mutability and Its Effect<\/h4>\n<ul>\n<li>Immutable objects (like <code>int<\/code>, <code>float<\/code>, <code>str<\/code>, <code>tuple<\/code>): cannot be changed in place. Any operation that seems to modify them actually creates a new object, leaving the original unchanged.<\/li>\n<li>Mutable objects (like <code>list<\/code>, <code>dict<\/code>, <code>set<\/code>): can be modified in place. Changes inside the function affect the original object outside the function.<\/li>\n<\/ul>\n<p>Understanding this distinction is crucial. It explains why immutable types behave like &#8220;call by value&#8221; (the original is unaffected) while mutable types behave like &#8220;call by reference&#8221; (the original can change). Once you internalize that Python always passes object references, the behavior of functions becomes predictable and intuitive.<\/p>\n<h2><a name=\"section-2\"><\/a>2. Python in Action: Passing Objects to Functions<\/h2>\n<p>The following example demonstrates how Python handles immutable and mutable objects when passed to a function.<\/p>\n<pre class=\"brush:python; wrap-lines:false;\">\ndef modify_immutable(num):\n    \"\"\"\n    Demonstrates call by value-like behavior using an immutable object (int).\n    Changes inside the function do NOT affect the original variable.\n    \"\"\"\n    print(\"Inside modify_immutable (before):\", num)\n    num = num + 10  # Creates a new integer object\n    print(\"Inside modify_immutable (after):\", num)\n\n\ndef modify_mutable(items):\n    \"\"\"\n    Demonstrates call by reference-like behavior using a mutable object (list).\n    Changes inside the function affect the original object.\n    \"\"\"\n    print(\"Inside modify_mutable (before):\", items)\n    items.append(4)  # Modifies the same list object\n    print(\"Inside modify_mutable (after):\", items)\n\n\ndef main():\n    # Immutable object\n    number = 5\n    print(\"Before calling modify_immutable:\")\n    print(\"number:\", number)\n    modify_immutable(number)\n    print(\"After calling modify_immutable:\")\n    print(\"number:\", number)  # Remains unchanged\n\n    print(\"\\n-----------------------------\\n\")\n\n    # Mutable object\n    my_list = [1, 2, 3]\n    print(\"Before calling modify_mutable:\")\n    print(\"my_list:\", my_list)\n    modify_mutable(my_list)\n    print(\"After calling modify_mutable:\")\n    print(\"my_list:\", my_list)  # Gets updated\n\n\n# Entry point\nif __name__ == \"__main__\":\n    main()\n<\/pre>\n<h3>2.1 Code Explanation<\/h3>\n<p>This program demonstrates Python\u2019s pass-by-object-reference behavior using both immutable and mutable objects. The function <code>modify_immutable()<\/code> takes an integer <code>num<\/code>, prints its initial value, adds 10, and prints it again; since integers are immutable, this operation creates a new object and does not change the original <code>number<\/code> variable in <code>main()<\/code>. In contrast, <code>modify_mutable()<\/code> takes a list <code>items<\/code>, prints its initial value, appends 4 to the list, and prints it again; because lists are mutable, this modifies the same object in memory, so changes are reflected in <code>my_list<\/code> outside the function. The <code>main()<\/code> function calls both functions and prints the state of the variables before and after the calls, clearly illustrating the difference between how Python handles immutable versus mutable objects when passed to functions.<\/p>\n<h3>2.2 Code Output<\/h3>\n<p>Run the following program using any Python interpreter (e.g., <code>python filename.py<\/code>) to observe how mutable and immutable objects behave when passed to a function.<\/p>\n<pre class=\"brush:plain; wrap-lines:false;\">\nBefore calling modify_immutable:\nnumber: 5\nInside modify_immutable (before): 5\nInside modify_immutable (after): 15\nAfter calling modify_immutable:\nnumber: 5\n\n-----------------------------\n\nBefore calling modify_mutable:\nmy_list: [1, 2, 3]\nInside modify_mutable (before): [1, 2, 3]\nInside modify_mutable (after): [1, 2, 3, 4]\nAfter calling modify_mutable:\nmy_list: [1, 2, 3, 4]\n<\/pre>\n<p>The output demonstrates how Python handles immutable and mutable objects differently when passed to functions. For the immutable integer <code>number<\/code>, the function <code>modify_immutable()<\/code> creates a new object when adding 10, so the original value remains <code>5<\/code> before and after the function call, showing call by value-like behavior. For the mutable list <code>my_list<\/code>, the function <code>modify_mutable()<\/code> appends <code>4<\/code> directly to the existing list object, so the change is reflected outside the function, resulting in <code>[1, 2, 3, 4]<\/code>, demonstrating call by reference-like behavior. This output clearly illustrates that Python passes object references to functions, and the effect depends on whether the object is mutable or immutable.<\/p>\n<h2><a name=\"section-3\"><\/a>3. Conclusion<\/h2>\n<p>Python does not strictly follow call by value or call by reference; instead, it uses pass by object reference, where function arguments are references to objects and the behavior depends on the object\u2019s mutability. Immutable objects tend to behave like call by value because changes create new objects, while mutable objects behave like call by reference since they can be modified in place. Understanding this model helps avoid common pitfalls, especially when working with lists, dictionaries, and other mutable data structures, making Python\u2019s behavior more predictable and intuitive once the concept is clear.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Understanding how Python handles variables and function arguments is essential for writing predictable and bug-free code. Many developers coming from languages like C++ or Java often wonder whether Python uses call by value or call by reference. The answer is: neither exactly. Python uses a model often called pass by object reference or call by &hellip;<\/p>\n","protected":false},"author":26931,"featured_media":219,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1878],"tags":[224],"class_list":["post-142596","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Understanding Python\u2019s Pass-by-Object-Reference Mechanism - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"How passing by object reference works in python: Learn how Python handles objects in functions using pass-by-object-reference.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/understanding-pythons-pass-by-object-reference-mechanism.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Understanding Python\u2019s Pass-by-Object-Reference Mechanism - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"How passing by object reference works in python: Learn how Python handles objects in functions using pass-by-object-reference.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/understanding-pythons-pass-by-object-reference-mechanism.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2026-04-08T14:46:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-08T14:46:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/python-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Yatin Batra\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Yatin Batra\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/understanding-pythons-pass-by-object-reference-mechanism.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/understanding-pythons-pass-by-object-reference-mechanism.html\"},\"author\":{\"name\":\"Yatin Batra\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/cda31a4c1965373fed40c8907dc09b8d\"},\"headline\":\"Understanding Python\u2019s Pass-by-Object-Reference Mechanism\",\"datePublished\":\"2026-04-08T14:46:55+00:00\",\"dateModified\":\"2026-04-08T14:46:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/understanding-pythons-pass-by-object-reference-mechanism.html\"},\"wordCount\":926,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/understanding-pythons-pass-by-object-reference-mechanism.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/python-logo.jpg\",\"keywords\":[\"Python\"],\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/understanding-pythons-pass-by-object-reference-mechanism.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/understanding-pythons-pass-by-object-reference-mechanism.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/understanding-pythons-pass-by-object-reference-mechanism.html\",\"name\":\"Understanding Python\u2019s Pass-by-Object-Reference Mechanism - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/understanding-pythons-pass-by-object-reference-mechanism.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/understanding-pythons-pass-by-object-reference-mechanism.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/python-logo.jpg\",\"datePublished\":\"2026-04-08T14:46:55+00:00\",\"dateModified\":\"2026-04-08T14:46:57+00:00\",\"description\":\"How passing by object reference works in python: Learn how Python handles objects in functions using pass-by-object-reference.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/understanding-pythons-pass-by-object-reference-mechanism.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/understanding-pythons-pass-by-object-reference-mechanism.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/understanding-pythons-pass-by-object-reference-mechanism.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/python-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/python-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/understanding-pythons-pass-by-object-reference-mechanism.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Web Development\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/web-development\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Python\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/web-development\\\/python\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Understanding Python\u2019s Pass-by-Object-Reference Mechanism\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/cda31a4c1965373fed40c8907dc09b8d\",\"name\":\"Yatin Batra\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"caption\":\"Yatin Batra\"},\"description\":\"An experience full-stack engineer well versed with Core Java, Spring\\\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).\",\"sameAs\":[\"https:\\\/\\\/www.javacodegeeks.com\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/yatin-batra\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Understanding Python\u2019s Pass-by-Object-Reference Mechanism - Java Code Geeks","description":"How passing by object reference works in python: Learn how Python handles objects in functions using pass-by-object-reference.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/understanding-pythons-pass-by-object-reference-mechanism.html","og_locale":"en_US","og_type":"article","og_title":"Understanding Python\u2019s Pass-by-Object-Reference Mechanism - Java Code Geeks","og_description":"How passing by object reference works in python: Learn how Python handles objects in functions using pass-by-object-reference.","og_url":"https:\/\/www.javacodegeeks.com\/understanding-pythons-pass-by-object-reference-mechanism.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2026-04-08T14:46:55+00:00","article_modified_time":"2026-04-08T14:46:57+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/python-logo.jpg","type":"image\/jpeg"}],"author":"Yatin Batra","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Yatin Batra","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/understanding-pythons-pass-by-object-reference-mechanism.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/understanding-pythons-pass-by-object-reference-mechanism.html"},"author":{"name":"Yatin Batra","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/cda31a4c1965373fed40c8907dc09b8d"},"headline":"Understanding Python\u2019s Pass-by-Object-Reference Mechanism","datePublished":"2026-04-08T14:46:55+00:00","dateModified":"2026-04-08T14:46:57+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/understanding-pythons-pass-by-object-reference-mechanism.html"},"wordCount":926,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/understanding-pythons-pass-by-object-reference-mechanism.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/python-logo.jpg","keywords":["Python"],"articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/understanding-pythons-pass-by-object-reference-mechanism.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/understanding-pythons-pass-by-object-reference-mechanism.html","url":"https:\/\/www.javacodegeeks.com\/understanding-pythons-pass-by-object-reference-mechanism.html","name":"Understanding Python\u2019s Pass-by-Object-Reference Mechanism - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/understanding-pythons-pass-by-object-reference-mechanism.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/understanding-pythons-pass-by-object-reference-mechanism.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/python-logo.jpg","datePublished":"2026-04-08T14:46:55+00:00","dateModified":"2026-04-08T14:46:57+00:00","description":"How passing by object reference works in python: Learn how Python handles objects in functions using pass-by-object-reference.","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/understanding-pythons-pass-by-object-reference-mechanism.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/understanding-pythons-pass-by-object-reference-mechanism.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/understanding-pythons-pass-by-object-reference-mechanism.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/python-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/python-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/understanding-pythons-pass-by-object-reference-mechanism.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Web Development","item":"https:\/\/www.javacodegeeks.com\/category\/web-development"},{"@type":"ListItem","position":3,"name":"Python","item":"https:\/\/www.javacodegeeks.com\/category\/web-development\/python"},{"@type":"ListItem","position":4,"name":"Understanding Python\u2019s Pass-by-Object-Reference Mechanism"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/cda31a4c1965373fed40c8907dc09b8d","name":"Yatin Batra","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","caption":"Yatin Batra"},"description":"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).","sameAs":["https:\/\/www.javacodegeeks.com"],"url":"https:\/\/www.javacodegeeks.com\/author\/yatin-batra"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/142596","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/26931"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=142596"}],"version-history":[{"count":1,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/142596\/revisions"}],"predecessor-version":[{"id":142597,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/142596\/revisions\/142597"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/219"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=142596"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=142596"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=142596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}