[FRPythoneers] propagate module variable changes

erick_bodine at comcast.net erick_bodine at comcast.net
Mon Nov 12 16:35:56 MST 2007


I am dynamically importing a module like the following, made simple for illustrative purposes.

module1
=======
v1a = 'one'
v1b = 'two'
v2 = 'values: %s, %s' % (v1a, v1b)

If I import "module1" and change the value of v1a, I would like that change to propagate to the module.v2 variable.

My initial idea is to parse the module file, replacing "v1a='one'" with the desired value, saving as 'module_changed.py' and importing 'module_changed' via __import__.  This will work, but feels like an ugly hack.  Any ideas?

--ERick



More information about the FRPythoneers mailing list