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/2003-October/039216.html below:

[Python-Dev] closure semantics

[Python-Dev] closure semantics [Python-Dev] closure semanticsWalter Dörwald walter at livinglogic.de
Tue Oct 21 19:06:30 EDT 2003
Guido van Rossum wrote:

> [...]
> Maybe "global x in f" would work?
> 
> def outer():
>     x = 1
>     def intermediate():
>         x = 2
>         def inner():
>             global x in outer
>             x = 42
>         inner()
>         print x      # prints 2
>     intermediate()
>     print x          # prints 42

Why not make local variables attributes of the function, i.e.
replace:

    def inner():
       global x in outer
       x = 42

with:

    def inner():
       outer.x = 42

Global variables could then be assigned via:
    global.x = 42

Could this be made backwards compatible?

Bye,
    Walter Dörwald



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