[Python-Dev] closure semantics

Skip Montanaro skip at pobox.com
Sat Oct 25 19:03:17 EDT 2003

    Greg> global <name>

    Greg> Assignments to <name> rebind it in the next outer scope where it
    Greg> is already bound, or in the module scope if there is no existing
    Greg> binding.

    Greg> Seems about the same length as yours.

Is that compatible with current use?  I think the current semantics are that
global <name> always binds name to an object with that name at module scope.

I thought the point of this discussion was to allow the programmer to
specify the precise scope of the object to which the variable would be
bound, in the face of possibly multiple occurrences of the name.  Using the
existing syntax you have to pick one rather arbitrarily, either the module
scope or the first place you find <name>.

(Again, I have never used nested functions, so this is more of a pedantic
argument than anything for me.  Still, it seems if you're going to change
things you should make it so any instance of an outer variable can be


More information about the Python-Dev mailing list