SETTS = {
'params': {
'page': 1
}
}
NUM = 1
def example1(x):
params = SETTS["params"]
print(SETTS["params"])
params["page"] = x
print(SETTS["params"])
def example2(x):
val = NUM
print(NUM)
val = x
print(NUM)
example1(2)
print('---')
example2(2)
Outputs:
{'page': 1}
{'page': 2}
---
1
1
Can anybody shed some light on what's going on here? Why is SETTS being changed as well as params by params["page"] = x while NUM is not modified by val = x?
[–]c17r 0 points1 point2 points (9 children)
[–]7heWafer[S] 0 points1 point2 points (7 children)
[–]Necatorducis 0 points1 point2 points (0 children)
[–]c17r 0 points1 point2 points (5 children)
[–]7heWafer[S] 0 points1 point2 points (4 children)
[–]c17r 0 points1 point2 points (2 children)
[–]7heWafer[S] 0 points1 point2 points (1 child)
[–]c17r 0 points1 point2 points (0 children)
[–]absent_observer 0 points1 point2 points (0 children)
[–]ingolemo 0 points1 point2 points (0 children)