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

[Python-Dev] Re: closure semantics

[Python-Dev] Re: closure semanticsSkip Montanaro skip at pobox.com
Thu Oct 23 21:56:26 EDT 2003
    Zack> Maybe "global foo from <function_name>" ?

Sounds just about like the "global foo in named_scope" (where "named_scope"
means enclosing function) that I described earlier.  I like "in" better than
"from" because it tells you more clearly that you are messing with the
variable in-place, not making a copy of it into the local scope.

    Zack> Or, "from function_name global foo" is consistent with import,
    Zack> albeit somewhat weird.

That reads a bit weird to me.  The nice thing about the other way is that
"global foo" without any qualifiers means the same thing it does today.
There's also no reason to use the from form as "global foo in function"
doesn't imply that you will refer to foo as "function.foo".

    Zack> I would never use this feature; I avoid nested functions entirely.
    Zack> However, as long as we're talking about this stuff, I wish I could
    Zack> write "global foo" at module scope and have that mean "this
    Zack> variable is to be treated as global in all functions in this
    Zack> module".

I've never actually used nested scopes either, nor have I ever felt the
urge.  Maybe it has something to do with not having done much recent
programming in a language before Python which supported them.  (Pascal does,
but my last Pascal experience was nearly 20 years ago.)

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