I have a simple python script which invokes the main function of another python script. Something like this:
invoker_code.py:
import os
invoked_code = '/tmp/invoked_code.py'
import sys
if os.path.exists(invoked_code):
sys.append(invoked_code)
else:
sys.exit(1)
import invoked_code
__data_bag = { 'var' : 'value' }
invoked_code.main()
/tmp/invoked_code.py:
def main():
print '%s' %(__data_bag['var'])
I want the invoked_code to be able to access the variable __dict_bag from within its code base. This should be achieved with minimal or zero code changes on the invoked_code.py script as this is a third party script and I do not have write access to this script. How can I do that?
invoked_code.pyget__data_bagfrom if is ran directly?__data_bagtoinvoked_code.main:invoked_code.main(__data_bag).