[Python-Dev] Re: Re: closure semantics

Terry Reedy tjreedy at udel.edu
Fri Oct 24 13:07:39 EDT 2003


"Delaney, Timothy C (Timothy)" <tdelaney at avaya.com> wrote in message
> I think these two points [consistency and teachability]
>should weigh heavily in any decision.

Agree also

>I think the need to rename the target scope is of lesser importance.

If you mean the need to sync the inner global-in statement with an
outer function name change, that is less onerous than the doing the
same for variable name changes (which might require changes to several
lines in the inner function).  Function name mismatches would, I
presume, be caught as compile-time syntax errors.

But what about name mismatches?  Global statements allows functions to
create 'new' variables in the module scope and not just 'existing'
ones.  What about for in-between scopes?

#start of fress interpreter session
def f():
  global xf
  xf = 1
  def g()
    global xg
    xg = 2
    global xgf in f
    xgf = 3

does this compile and run?  or choke on third global at compile time?
or choke on third assignment at runtime?

Terry J. Reedy






More information about the Python-Dev mailing list