Is it possible to change the value of a variable in the outer function
if you are in a nested inner function?

For example:

def outer():
     a = "outer"
     def inner():
          print a
          a = "inner"
               # I'm trying to change the outer 'a' here,
               # but this statement causes Python to
               # produce an UnboundLocalError.
     return inner

What I'm trying to do here is to get the following output from these
lines of code?
# Code:
func = outer()
func()
func()
func()

# Output:
outer
inner
inner

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to