Given following code:
def A() :
b = 1
def B() :
# I can access \'b\' from here.
print( b )
# But can i modify \'b\' here? \'
I'm a little new to Python, but I've read a bit about this. I believe the best you're going to get is similar to the Java work-around, which is to wrap your outer variable in a list.
def A():
b = [1]
def B():
b[0] = 2
B()
print(b[0])
# The output is '2'
Edit: I guess this was probably true before Python 3. Looks like nonlocal
is your answer.