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

[Python-Dev] closure semantics

[Python-Dev] closure semantics [Python-Dev] closure semanticsMoore, Paul Paul.Moore at atosorigin.com
Fri Oct 24 04:02:15 EDT 2003
From: Delaney, Timothy C (Timothy) [mailto:tdelaney at avaya.com]
> It would break any unadorned 'global x' in a nested scope
> if the name did not exist anywhere.

> I'm not saying this would be good form - personally I think
> anyone who did this would deserve it - but it would definitely break.

> One option would be to have an "if the name doesn't exist, it it
> created in module scope". But all this creates too many exceptions
> to what would otherwise be a simple rule IMO:
>
>    global <name> [in <scope>]
>
> where <scope> default to the current module.

This made me think. What should be the effect of

    def f():
        x = 12
        def g():
            global y in f
            y = 12
        g()
        print locals()

I suspect the answer is "it's illegal". But by extension from the current
behaviour of "global", it should create a local variable in f.

Paul

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