using a func param in a nested function

Hans Nowak ivnowa at hvision.nl
Tue Feb 6 03:44:19 EST 2001


Steven D. Arnold wrote:
> 
> Hi,
> 
> I know this is illegal:
> 
>          def a(self, *x):
>                  def b(m, n):
>                          global x
>                          for pref in x:
> 
> The documentation says that you can't use global with a name defined as a
> formal parameter in a function.  The question, then, is how can I use x in
> function b, other than by passing it as a parameter?  

As far as I understand, the new scoping rules in Python 2.1 will fix
this. Take a look at this document:

  http://amk.ca/python/2.1/

--Hans Nowak



More information about the Python-list mailing list