I am trying to replace the value of a dict object. The following script works:
> d = {'a': 1}
> def f(d):
> return {'b': 2}
> d = f(d)
> print d
{'b': 2}
But this one not:
> d = {'a': 1}
> def replace(d):
> d = {'b':2}
> replace(d)
> print d
{'a': 1}
Why exactly?
And is it thus necessary to do d.pop(k) for all keys then d.update(...) to be able to change the entirety of a dict?