Dear Ranjit,
It is not the interpreter alone in action and it flutters. From my learning by
going through the articles below.
It works in conjunction with Symbol table to determine the scope of each name
binding. So, before it reaches the print(x) in case 2. It has the symbol table
prepared for
On Saturday 02 July 2016 11:26 PM, ranjith pillay wrote:
But its kind of intriguing. In the 1st case the interpreter does not
find x in the local name space but finds it in the enclosing namespace.
The same argument should hold true for the 2nd case. I am not assigning
a new value to x but only p
the variable 'x' defined outside the scope of the function f is a global
variable. Python allows access of the global variable within the function.
But when you assign the value x=5, it starts to treat x as a local
variable. When there is a print statment before the assignment, you get
unbound loc