On Jun 11, 1:37 pm, [EMAIL PROTECTED] wrote: > On Jun 11, 11:02 am, reubendb <[EMAIL PROTECTED]> wrote: > > > > > Hello, > > I am new to Python. I have the following question / problem. > > I have a visualization software with command-line interface (CLI), > > which essentially is a Python (v. 2.5) interpreter with functions > > added to the global namespace. I would like to keep my own functions > > in a separate module and then import that module to the main script > > (that will be executed using the CLI interpreter). The problem is, I > > cannot access the functions in the global namespace of the main script > > from my module. Is there anyway to do that ? > <snip> > > I think you're doing it backwards. If you want access to AddPlot, then > you should import mainscript into that module instead of the other way > around. When I have common methods I want to call from different > scripts, I put those methods/functions into their own module/file. > Then I just import the module and call whatever script I need. > > <code> > > commonMods.py > --------------------- > AddPlot(*args, *kwargs): > # Do something > DrawPlots(*args, *kwargs): > # Do something > ---------------------
Hi Mike, The problem is I don't define the functions AddPlot() and DrawPlots(). It's built into the python interpreter of the CLI version of the program I mentioned, and they are defined on the main script. I load the main script using something like "software -cli -s mainscript.py". In the mainscript.py I import myModule, but of course myModule does not have access to the functions defined in the global namespace of mainscript.py. Thanks. RDB -- http://mail.python.org/mailman/listinfo/python-list