> what's the Python way of accessing local variables
> in nesting functions?
THats usually bad practice, and since it is a nested function
why not just return a value?
def p():
var1 = 3
def q():
print 'var1 in p is', var1
return 42
var1 = q()
After all var1 only exists within p(
On 13 Feb 2005, [EMAIL PROTECTED] wrote:
> what's the Python way of accessing local variables in nesting functions? For
The way you want to work with closures the Python way is not to do it
but use a class to hold the state. That's sometimes sad but true.
> example if I have:
>
> def p():
>
Hello all,
what's the Python way of accessing local variables in nesting functions? For
example if I have:
def p():
var1 = 3
def q():
print 'var1 in p is', var1
q()
then there's no problem in running such function, but what if I'd like to
modify var1 so that the change were vissible