A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2006-July/067144.html below:

[Python-Dev] Explicit Lexical Scoping (pre-PEP?)

[Python-Dev] Explicit Lexical Scoping (pre-PEP?) [Python-Dev] Explicit Lexical Scoping (pre-PEP?)skip at pobox.com skip at pobox.com
Sat Jul 8 00:10:04 CEST 2006
    Guido> Well, personally I'm for allowing full rebinding semantics but
    Guido> only when a 'global' (or 'nonlocal') statement is used
    Guido> first. Making augmented assignment automatically imply 'global'
    Guido> etc. seems too magical to me.

So, if I understand correctly, in the presence of a global statement search
just goes up the lexical chain looking for the first occurrence of the
variable to modify?

    x = 0
    def f():
        x = 1
        def g():
            global x
            x = 2
            print x
        g()
        print x
    f()
    print x

Today it prints

    2
    1
    2

You're suggesting it will print 

    2
    2
    0

?

Sounds reasonable to me.  If we're talking py3k I'd chuck "global" as a
keyword though and replace it with something like "outer".

Skip
More information about the Python-Dev mailing list

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