global in nested functions (viper)

Guido van Rossum guido at cnri.reston.va.us
Tue Sep 21 15:57:39 EDT 1999


skaller <skaller at maxtal.com.au> writes:

> The following file and viperi run demonstrate the current handling
> of the globals statement in viper.  What happens is: global causes
> a variable to refer to the containing context, often a module,
> but in this demo, there is also a nested function, global then refers
> to the locals() of the containing function, unless the variable
> is _also_ declared 'global' in that function.

Hm, this looks elegant, although I also see the elegance of
disallowing assignments into the parent function altogether (i.e., you
can *read* your parent's locals, but you can't *write* them).  So I'm
undecided.

--Guido van Rossum (home page: http://www.python.org/~guido/)




More information about the Python-list mailing list