Aug-22-2019, 04:22 AM
I tried out like this
class Spam: pass def fun(a): a.foo=5 print(a.foo) print(id(a.foo)) foo=6 id1=5 s=Spam() fun(s) print(s.foo) print(foo) print(id(foo)) print(id1) print(id(id1))And the output is
Output:5
1918656864
5
6
1918656896
5
1918656864
Interesting.. looks like the same memory reference for value 5 is being shared by both variables a.foo and id1