|
|
|
|
|
by froh
669 days ago
|
|
you replace the local binding z to the dict globally bound to x by a local dict in that z = ... assignment. however if you do z['b'] = 2 in foo, then you'll see the global dict bound to x has been modified, as you have stated. well, that's _exactly_ pass by reference. |
|
Pass-by-reference doesn't exist in Python. Here's what it looks like in C#, which does suport it:
Here z is just a new name for x. Any change you make to z, including changing its value, applies directly to x itself, not just to the object referenced by x.