using a func param in a nested function

Steven D. Arnold stevena at neosynapse.net
Tue Feb 6 02:01:04 EST 2001


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?  I've already tried this:

         def a(self, *x):
                 y = deepcopy(x)
                 def b(m, n):
                         global y
                         for pref in y:

That approach doesn't work either.  Ideas?


--
Steven D. Arnold          Que quiero sera         stevena at neosynapse.net
"He was part of my dream, of course -- but then  I was part of his dream
too."                                                   -- Lewis Carroll





More information about the Python-list mailing list