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 of Python 2.2, scopes nest, as per PEP 227.
We still need a mutable, but not a default argument:
def outer():
a = ["outer"]
def inner():
print a[0]
a[0] = "inner"
return inner
--
--Bryan
--
http://mail.python.org/mailman/listinfo/python-list