A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2000-November/010284.html below:

[Python-Dev] Re: Dynamic nested scopes

[Python-Dev] Re: Dynamic nested scopes [Python-Dev] Re: Dynamic nested scopesJeremy Hylton jeremy@alum.mit.edu
Thu, 2 Nov 2000 12:57:09 -0500 (EST)
I don't think I buy your explanation that Python uses dynamic scope
for resolving globals.  As I understand the mechanism, the module
namespace and builtins namespace are those for the module in which the
function was defined.  If so, this is still static scope.

Here's a quick example that illustrates the difference:

module foo:
-----------------------
a = 12

def add(b):
    return a + b
-----------------------

module bar:
-----------------------
from foo import add

a = -1
print add(1)
-----------------------

If Python used static scope, "python bar.py" should print 13 (it
does).  If it used dynamic scope, I would expect the answer to be 0.

Jeremy



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4