Apr-24-2017, 05:04 PM
(Apr-24-2017, 07:04 AM)Sello Wrote:# This is File A from fileb import bvar bvar = 10
There seem to be a lot of assumptions that you want to save that value to the original file, so the next time you open up
fileb
, it'd be 10 instead of whatever it used to be. I'm not sure that's what you're asking. If you just want to change it while it's running, sort of like a config value, then work with the file as a module directly, instead of only importing the single variable. Like so:#file a import fileb print(fileb.bvar) # 5, maybe fileb.bvar = 10 print(fileb.bvar) # 10 here, and also 10 for anything in fileb that uses itAlthough you'd need a pretty good reason to want to do that, since it could easily make reading fileb and understanding why the output is as it is fairly complicated.