[EMAIL PROTECTED] wrote:
Is it possible to change the value of a variable in the outer function
if you are in a nested inner function?
Depends on what you mean by changing the value. If you mean mutating a
mutable object, yes, it's possible. If you mean rebinding the name to a
different object,
Ben Cartwright wrote:
The typical kludge is to wrap the variable in the outer function inside
a mutable object, then pass it into the inner using a default argument:
def outer():
a = outer
def inner(wrapa=[a]):
print wrapa[0]
wrapa[0] = inner
return inner
As
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
[EMAIL PROTECTED] wrote:
Is it possible to change the value of a variable in the outer function
if you are in a nested inner function?
The typical kludge is to wrap the variable in the outer function inside
a mutable object, then pass it into the inner using a default argument:
def outer():