We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
Required fields*
19
78
-1. The code shown is good, the explanation as to how is completely wrong. See the answers by DavidCournapeau or DarenThomas for correct explanations as to why.
"...parameter passed in..." is incorrect use of terminology. A parameter is a named entity in a function (or method) definition that specifies an argument (or in some cases, arguments) that the function can accept. An argument is a value passed to a function (or method) when calling the function.
@EthanFurman You are wrong. Even if you read the link in DavidCournapeau's answer that is Call By Object, you will see that all of the expressions "call by object", "call by sharing" or "call by object reference", have the same meaning that is using an address to access the object. And for sure the address has to be determined from namespace. I can't accept that "Call by object reference" is different from "Call by reference".
@ML_Pro, "pass by assignment" seems to be a term made up by the Python documenters to describe "pass by value". For the user, I see no functional difference between passing a value that is a reference (or handle) as happens in languages such as Java or C# and what Python does, and I'd never use the term "pass by assignment"; it was edited into the answer, I assume to align with the documentation.
@HappyAhmad it absolutely is different to call by reference. If Python supported call by reference, you could do something like def foo(&var): var = 2 then x = 0; y = 1; foo(x); foo(y) then print(x, y) would print 2 2
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
complete the sentence: my question is about...
use tags that describe things or concepts that are essential, not incidental to your question
def foo(&var): var = 2thenx = 0; y = 1; foo(x); foo(y)thenprint(x, y)would print2 2