I'm using Python in a scripting environment. The host application would pass in some objects so that the script can act on it. But there are a number of things I like to add to every script to make it a decent environment, for example, setting up exception hook to show error properly. I tried to factorize this into a module called script_util. For example:
------------------------------------------------------------------------ script: # host application would pass in objects like window, document, etc. import script_util ... do something with window, document, etc, ... ------------------------------------------------------------------------ script_util.py: import sys def myExceptionHandler(...): importer.window.alert(message) sys.excepthook = myExceptionHandler sys.stdout = myOutputPipe ------------------------------------------------------------------------ However in order for script_util to work, it needs to have access to the importer's context to get access to the host objects. Is there anyway for it to find out? I guess I can do something like: ------------------------------------------------------------------------ import script_util script_util.init(globals()) ------------------------------------------------------------------------ But I like to make something brain dead easy with just the import statement if possible. Thank you, wy -- http://mail.python.org/mailman/listinfo/python-list