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/066906.html below:

[Python-Dev] Lexical scoping in Python 3k

[Python-Dev] Lexical scoping in Python 3kNeil Schemenauer nas at arctrix.com
Sat Jul 1 17:41:29 CEST 2006
Ka-Ping Yee <python-dev at zesty.ca> wrote:
> Most other languages that support lexical scoping (including Scheme,
> JavaScript, Ruby, Perl, E, Java, Smalltalk) provide a uniform way
> to read and write to scopes at all levels.  This is done by letting
> programmers specify the scope in which they want a variable bound
> (usually with a keyword like "var" in JavaScript, "my" in Perl, or
> "define" in E).

That's not the Python way, IMO.  I think the right way (assuming we
actually want to allow it) is to introduce a pure assignment
statement in addition to the assignment/declaration statement that
we already have.  For example:


    a = 1 
    def f():
        b = 2
        a := 2
        def g():
            b := 3
            print a, b, c
        g()
    f()
    
would print "2 3 4".  The := would assign but not declare a variable
in the current scope.

  Neil

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