>>> def nil():
... ss='nil'
... print ss
...
>>> nil()
nil
>>> nil.ss='kk'
>>> nil()
nil
>>> print nil.ss
kk
I know everything is an object in python, so function is also an object, now I wanna change the value of ‘ss’ variable, which is stored in function , now I tried to change its value by using nil.ss but it didn;t change..What is the diff between both ‘ss’?
The first
ssis an inner variable of the function; the second one is an attribute of the function. They don’t reference the same object.Here’s a way to do it, though: