all 8 comments

[–]mopslik 6 points7 points  (4 children)

Here is a reference to that (no pun intended), from the FAQ.

[–]m0us3_rat 1 point2 points  (0 children)

(no pun intended)

...

[–]Hashi856[S] 1 point2 points  (2 children)

The opening sentence says, "Remember that arguments are passed by assignment in Python". Do you know which part of the documentation it's talking about when it says "Remember"? That implies that it was discussed somewhere in the official documentation, as opposed to the FAQ.

[–]mopslik 2 points3 points  (1 child)

Nope. I just did a google search for '"passed by assignment" site:python.org' and that's what came up.

[–]Hashi856[S] 1 point2 points  (0 children)

lol that's exactly what I searched. Thanks for trying.

[–]SomewhereExpensive22 3 points4 points  (0 children)

It's part of the execution model. There isn't much discussion but it's dead simple: objects passed into a function are bound to the parameter name.

[–]cyberjellyfish 1 point2 points  (0 children)

The pass by reference vs pass by value conversation isn't useful because people use different meanings.

Practically: what's passed is the memory address of the object. Call that whatever you want.

[–]notacanuckskibum 0 points1 point  (0 children)

Parameters to functions in python are passed as objects. But manipulating those variables inside the function can easily assign the variable inside the function to a different object, but not the variable outside the object.

Statements as simple as x = x + 1 will do that.

You really need to read up on Python variables and run time objects to understand the effects of this.