#Illustrate lexical scoping def incr(x): # Since first use of increment defines a value for it # Python introduces a new variable increment = 3 x = x + 3 return x def decr(x): # Note that value of variable increment has not been locally defined # Python will search in enclosing scope for this variable x = x - increment return x increment = 1 print 'Test scope rules' x = 10 #Create a new variable x and bind it to the int 10 print x print incr(x) print x # Note that value of x is unchanged by call to incr print decr(x)