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 printing it. It should have found the x in the enclosing namespace. I would like to understand this from the interpreter's view. Python being a dynamically interpreted language, which in simple terms would mean interpreting each line of code. I was trying to understand how the interpreter behaves when it encounters the def keyword and how it assigns namespaces.
Each function is parsed and converted to byte code before being interpreted. So it is not like Python is executing code line by line. Regards, Vijay _______________________________________________ Chennaipy mailing list Chennaipy@python.org https://mail.python.org/mailman/listinfo/chennaipy