nonlocal fails ?

R.Wieser address at not.available
Thu Nov 14 09:15:14 EST 2019


Jan,

> The nonlocal statement causes the listed identifiers to refer to 
> previously bound variables in the nearest ******enclosing scope excluding 
> globals******.

I read that too, but didn't get from it that the main scope is excluded (I 
assumed the"excluding globals" was ment at as such declared variables) . 
Thanks the clarification.

Too bad though, it means that procedures that want to share/use its callers 
variables using nonlocal can never be called from main.  And that a caller 
of a procedure using nonlocal cannot have the variable declared as global 
(just tested it).

Regards,
Rudy Wieser




More information about the Python-list mailing list