"pasa" <[EMAIL PROTECTED]> wrote in message

> Do functions carry their own pointer to global namespace,
> which gets defined at function compile time, or what is
> happening here?
To expand on Just's answer:

For lexical scoping --  resolution of globals in the definition context --  
some reference to that context is required.  The alternative of dynamic 
scoping -- resolution of globals in the calling context -- has been tried 
in other languages and found wanting.  For instance, if you call a function 
in the math module that uses pi, sin, or cos, one almost certainly wants it 
to use the object defined and bound to pi, sin, or cos in the math module. 
That happens automatically with lexical scoping.  With dynamic scoping, one 
would have to do 'from math import *' first.  And so on for everything 
else.

Terry J. Reedy



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to