I have some code like this:
def f():
i = 5
g(locals())
print 'in f:', i, j
def g(env):
env['j'] = env['i'] + 1
print 'in g:', env['i'], env['j']
f()
I get:
in g: 5 6
in f: 5---------------------------------------------------------------------------
NameError Traceback (most recent call last)
NameError: global name 'j' is not defined
It seems that g cannot change the local variables got by locals() in f. Is there anyway to change the local variables in other function?