|
|
|
|
|
by rockemsockem
1295 days ago
|
|
That example actually holds with what the parent comment said. You aren't trying to modify d exactly, you're modifying d's contents. Python 3.8.10 (default, Jun 22 2022, 20:18:18)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more
information.
>>> def f(d):
... d = {'foo': 'bar'}
...
>>> a = {}
>>> f(a)
>>> a
{}
does not modify the passed in dictionary, because the reference 'd' itself is passed by value. So the function doesn't change what d references for the caller. Java works the same way. |
|