def func(x):
print "inside function" ,id(x)
x = 2
x = 50
print "outside function" ,id(x)
print 'Value of x before function call is', x
func(x)
print 'Value of x after function call is', x
output:
outside function 6486996
Value of x before function call is 50
inside function 6486996
Value of x after function call is 50
Assuming that id()
gives memory location of object. Even though both are saving at the same location, if x value is changed in func()
, it is not effected outside.